Adding a translated attribute to a tag

 < Day Day Up > 

Attribute translation relies on the Dreamweaver parser to ignore server markup. By default, Dreamweaver already ignores the most common kinds of server markup (including ASP, CFML, and PHP); if you use server markup that has different opening and closing markers, you must modify the third-party tag database to ensure that your translator works properly. For more information on modifying the third-party tag database, see "Customizing Dreamweaver" in Using Dreamweaver.

When Dreamweaver handles preserving the original server markup, the translator generates a valid attribute value that can be viewed in the Document window. (If you use server markup only for attributes that do not have a user-visible effect, you do not need a translator.)

The translator creates an attribute value that has a visible effect in the Document window by adding a special attribute, mmtranslatedValue, to the tag that contains the server markup. The mmTRanslatedValue attribute and its value are not visible in the HTML panel or in Code view, nor are they saved with the document.

The mmTRanslatedValue attribute must be unique within the tag. If it is likely that your translator needs to translate more than one attribute in a single tag, you must add a routine in the translator that appends numbers to the mmTRanslatedValue attribute (for example, mmTRanslatedValue1, mmTRanslatedValue2, and so on).

The value of the mmtranslatedValue attribute must be a URL-encoded string that contains at least one valid attribute/value pair. This means that mmTRanslatedValue="src=%22open.jpg%22" is a valid translation for both src="/books/4/533/1/html/2/<? if (dayType == weekday) then open.jpg else closed.jpg" ?> and <? if (dayType == weekday) then src="/books/4/533/1/html/2/open.jpg" else src="/books/4/533/1/html/2/closed.jpg" ?>. mmTRanslatedValue="%22open.jpg%22" is not valid for either example because it contains only the value, not the attribute.

Translating more than one attribute at a time

The mmtranslatedValue attribute can contain more than one valid attribute/value pair. Consider the following untranslated code:

 <img <? if (dayType==weekday) then src="/books/4/533/1/html/2/open.jpg" width="320" height="100" else src="/books/4/533/1/html/2/closed.jpg" width="100" height="320" ?> alt="We're open 24 hours a day from 12:01am Monday until 11:59pm Friday"> 

The following example shows how the translated markup might appear:

 <img <? if (dayType==weekday) then src="/books/4/533/1/html/2/open.jpg" width="320" height="100" else src="/books/4/533/1/html/2/closed.jpg" width="100" height="320" ?> mmTranslatedValue="src=%22open.jpg%22 width=%22320%22 height=%22100%22" alt="We're open 24 hours a day from 12:01am Monday until 11:59pm Friday"> 

The spaces between the attribute/value pairs in the mmTRanslatedValue attribute are not encoded. Because Dreamweaver looks for these spaces when it attempts to render the translated value, each attribute/value pair in the mmTRanslatedValue attribute must be encoded separately and then pieced back together to form the full mmTRanslatedValue attribute. For an example of this process, see "A simple attribute translator example" on page 443.

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net