Detecting if a template is applied in extension writing

Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default Detecting if a template is applied in extension writing

    Hello,

    I have been working on an extension which inserts code into my page at the
    selection point, but also inserts a link to an external javascript file. The
    glitch comes with a template page. The javascript link gets inserted into an
    "uneditable region" Anyone have any tips on detecting if the document has a
    template applied and then inserting the link into the editable region of the
    head.

    neo314 Guest

  2. Similar Questions and Discussions

    1. Extension template/skeleton
      Hi Does anyone/adobe have an extension template/skeleton to get newbies started with? Best practice file management with useful things like...
    2. Writing an extension
      Dear Friends, I want to write an extension for Adobe Dreamweaver CS3 and also add an autocompletion-feature. Is there a good tutorial for...
    3. Writing a Dreamweaver Extension, where to start?
      Hello, I want to learn how to write a dreamweaver CS4 extension, but the only material I can seem to find that provides step by step instructions...
    4. perl template tool kit extension development
      Greetings, I would like to develop an extension to dreamweaver to allow DW to visually display the perl Template Toolkit .wld files. For those...
    5. [PHP-DEV] When can I expect changes to be applied
      Hello, I requested some time ago that zend_parse_parameters() be altered to accept "Z" as a parameter type in order to be able to retrieve...
  3. #2

    Default Re: Detecting if a template is applied in extension writing

    "neo314" <webforumsuser@macromedia.com> wrote in message
    news:fg0cs9$dic$1@forums.macromedia.com...
    > Anyone have any tips on detecting if the document has a
    > template applied
    getAttachedTemplate() should work


    --
    ----------------------------
    Massimo Foti, web-programmer for hire
    Tools for ColdFusion and Dreamweaver developers:
    [url]http://www.massimocorner.com[/url]
    ----------------------------


    Massimo Foti Guest

  4. #3

    Default Re: Detecting if a template is applied in extensionwriting

    Assuming that returns null or false if there is no template applied, my main
    concern is finding the editable space within the head and inserting there
    instead of at the end of the head tag.

    I have not seen the equivalent of getEditableHead(). I do see how to get a
    list of editable regions. Does one determine if there is a template; retrieve
    the editable regions; and search the source of the head tag for each region to
    find which is inside the head tag, or is there a better way? That method seems
    cumbersome.

    neo314 Guest

  5. #4

    Default Re: Detecting if a template is applied in extension writing

    "neo314" <webforumsuser@macromedia.com> wrote in message
    news:fg1lfi$3e8$1@forums.macromedia.com...
    > Assuming that returns null or false if there is no template applied
    As far as I remember it should return an empty string in that case. But I
    may be wrong, you better check by yourself


    > my main
    > concern is finding the editable space within the head and inserting there
    > instead of at the end of the head tag.
    I didn't answered to this because I don't have a good solution to the
    problem... Sorry


    --
    ----------------------------
    Massimo Foti, web-programmer for hire
    Tools for ColdFusion and Dreamweaver developers:
    [url]http://www.massimocorner.com[/url]
    ----------------------------


    Massimo Foti Guest

  6. #5

    Default Re: Detecting if a template is applied in extension writing

    dw.getDocumentDOM().getEditableRegionList()

    Then loop thru that array looking at each for a headregion's comment.

    --


    E. Michael Brandt

    [url]www.divaHTML.com[/url]
    divaPOP : standards-compliant popup windows
    divaGPS : you-are-here menu highlighting
    divaFAQ : FAQ pages with pizazz

    [url]www.valleywebdesigns.com/vwd_Vdw.asp[/url]
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

    --
    E Michael Brandt Guest

  7. #6

    Default Re: Detecting if a template is applied in extensionwriting

    Thanx
    neo314 Guest

  8. #7

    Default Re: Detecting if a template is applied in extensionwriting

    Thanx for that tid bit. I'd like to ask for a little more help.

    I was really hoping for a method that determines if any given element is in an
    editable region.

    I can now detect if a template is applied. If one is applied, I can find the
    editable region of the head instead of just inserting at the end of the head
    tag.

    Now I have a list of all the textareas on the page. Any good ideas for the
    best way to test whether each one is in an editable region so I can exclude the
    textareas that are not in an editable region.

    This is probably not an issue for this project since textareas will rarely be
    in a non-editable region, but I'm trying to figure out how to deal with
    templates.

    My only thought at this point is get the list of editable regions, get the
    offsets of each region, and see if the offsets of each textarea are withing an
    editable region. This seems to require two or more loops.

    Is that the best solution?



    neo314 Guest

  9. #8

    Default Re: Detecting if a template is applied in extension writing


    I typically do something like this in the opposite direction - I loop
    through the array of editable regions looking for whatever features I am
    interested in finding.

    --


    E. Michael Brandt

    [url]www.divaHTML.com[/url]
    divaPOP : standards-compliant popup windows
    divaGPS : you-are-here menu highlighting
    divaFAQ : FAQ pages with pizazz

    [url]www.valleywebdesigns.com/vwd_Vdw.asp[/url]
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

    --
    E Michael Brandt Guest

  10. #9

    Default Re: Detecting if a template is applied in extensionwriting

    In other words, do what I have done if no template is applied, and if one is applied, loop through the editable regions looking for textareas...

    That makes sense.
    neo314 Guest

  11. #10

    Default Re: Detecting if a template is applied in extensionwriting

    As a follow-up to this, I thought I would share what I did...

    I first check for a template. If not insert into the head tag.
    If there is a template,
    loop through editable regions checking whether they are in the head.
    for each in the head,
    if one is named 'head' use that one;
    Otherwise use the second editable region (the first is usually the
    title);
    Otherwise, if only one editable region use that one.
    If no editable region, return an error.


    neo314 Guest

  12. #11

    Default Re: Detecting if a template is applied in extension writing


    I have found it best not to use the "title" region to insert your code,
    rather check for the "head" region, and if not found, either create it
    or return an error. Using the title region makes for headaches down the
    line.

    --


    E. Michael Brandt

    [url]www.divaHTML.com[/url]
    divaPOP : standards-compliant popup windows
    divaGPS : you-are-here menu highlighting
    divaFAQ : FAQ pages with pizazz

    [url]www.valleywebdesigns.com/vwd_Vdw.asp[/url]
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

    --
    E Michael Brandt Guest

  13. #12

    Default Re: Detecting if a template is applied in extensionwriting

    I'm not using the title region unless it is the only editable region.
    neo314 Guest

  14. #13

    Default Re: Detecting if a template is applied in extension writing

    neo314 wrote:
    > I'm not using the title region unless it is the only editable region.
    yep, that's what I am saying. It is best NOT to do that. It can cause
    difficulties when the page interacts with other behaviors, and
    especially causes trouble when the page is edited later in DWMX+ (the
    pages with title regions only were created in DW4.)

    So, if it is a DW4-originated page, abort with an alert explaining why.

    --


    E. Michael Brandt

    [url]www.divaHTML.com[/url]
    divaPOP : standards-compliant popup windows
    divaGPS : you-are-here menu highlighting
    divaFAQ : FAQ pages with pizazz

    [url]www.valleywebdesigns.com/vwd_Vdw.asp[/url]
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

    --
    E Michael Brandt Guest

  15. #14

    Default Re: Detecting if a template is applied in extension writing



    "E Michael Brandt" <michael@valleywebdesigns.com> wrote in message
    news:fhltu9$ifs$2@forums.macromedia.com...
    > neo314 wrote:
    >> I'm not using the title region unless it is the only editable region.
    >
    > yep, that's what I am saying. It is best NOT to do that. It can cause
    > difficulties when the page interacts with other behaviors, and especially
    > causes trouble when the page is edited later in DWMX+ (the pages with
    > title regions only were created in DW4.)
    >
    > So, if it is a DW4-originated page, abort with an alert explaining why.
    Yes I can confirm that I just got a template with meta tags in the docTitle
    region and that these aren't propagating to childpages.

    So when there's no editable region in the head, what should we do then?
    Edit the parent template to add a region or have the user deceide from the
    "Changes to locked region" dialog?

    --
    Joris van Lier

    Joris van Lier Guest

  16. #15

    Default Re: Detecting if a template is applied in extensionwriting

    Ok, I understand. I'm glad I posted the follow-up.

    I wasn't including the title/docTitle region so much as choosing head first,
    and the second editable region first and the only editable region last.

    I have not considered having the user create a new editable region or change
    the template. My plan is/was to return an error if there is no place to add the
    javascript in the head.

    To that end. I can drop the use second and if not use the only available
    routine. Instead I can just exclude title and docTitle regions. Use head first
    and any other available region if none are named head having excluded the title
    region. Return an error otherwise.

    I'm open to a better solution however. Thanks for the feedback.

    Steven

    neo314 Guest

  17. #16

    Default Re: Detecting if a template is applied in extension writing

    >
    > I'm open to a better solution however. Thanks for the feedback.
    My anwser, as I said before, is never to use anything but the "head"
    editable region. This is what I tell my Extension users: the first FAQ
    on this page:

    [url]http://valleywebdesigns.com/vwd_jspA3/vwd_jspA3_faq.asp[/url]

    --


    E. Michael Brandt

    [url]www.divaHTML.com[/url]
    divaPOP : standards-compliant popup windows
    divaGPS : you-are-here menu highlighting
    divaFAQ : FAQ pages with pizazz

    [url]www.valleywebdesigns.com/vwd_Vdw.asp[/url]
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

    --
    E Michael Brandt Guest

  18. #17

    Default Re: Detecting if a template is applied in extension writing

    > Yes I can confirm that I just got a template with meta tags in the
    > docTitle region and that these aren't propagating to childpages.
    hmm. well you would not expect them to. Nothing in any editable region
    would propagate to child pages. Being editable menas they are unique to
    that page.

    > So when there's no editable region in the head, what should we do then?
    > Edit the parent template to add a region or have the user deceide from
    > the "Changes to locked region" dialog?
    See the first FAQ on this page to see what I tell my Extension users:

    [url]http://valleywebdesigns.com/vwd_jspA3/vwd_jspA3_faq.asp[/url]


    E. Michael Brandt

    [url]www.divaHTML.com[/url]
    divaPOP : standards-compliant popup windows
    divaGPS : you-are-here menu highlighting
    divaFAQ : FAQ pages with pizazz

    [url]www.valleywebdesigns.com/vwd_Vdw.asp[/url]
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

    --
    E Michael Brandt Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139