Skip to main content
Inspiring
January 22, 2009
Answered

Server Format Extension

  • January 22, 2009
  • 4 replies
  • 1439 views
I figured out how to add a server format that would include two functions -- addslashes(htmlentities({data element}))

The only remaining issue is it changes to a php icon in design view. Anyone know where/how that display is determined so I can get a standard dynamic data display {dynamic.data} in design view.

For any who are interested, or if it pertains to my question, here are the code modifications:.

This topic has been closed for replies.
Correct answer
You'll be adding your own edml file to do the translation. You should just use the ones in that folder as an example. Without testing the code it, my guess is it should look something like:

<participant name="transDynDataMyFormat">
<translator priority=400>
<searchPatterns>
<searchPattern><![CDATA[echo]]></searchPattern>
<searchPattern><![CDATA[addslashes]]></searchPattern>
<searchPattern paramNames="innerArg"><![CDATA[/\s*php\s*echo\s*addslashes\(htmlentities\(([^\r\n]*)\)\);?\s*/i]]></searchPattern>
</searchPatterns>
<translations>
<translation whereToSearch="directive" translationType="dynamic data">
<openTag>MM_DYNAMIC_CONTENT</openTag>
<display><![CDATA[{@@innerArg@@}]]></display>
<closeTag>MM_DYNAMIC_CONTENT</closeTag>
</translation>
<translation whereToSearch="tag+INPUT" limitSearch="attribute+VALUE" translationType="dynamic data">
<attributes>
<attribute><![CDATA[mmTranslatedValueDynValue="VALUE={@@rinnerArg@@}"]]></attribute>
</attributes>
</translation>
</translations>
</translator>
</participant>


I think the only tricky part is the paramNames on the search pattern just name the paren() matches from the regex. You'll see I added an extra () instead the call the htmlentities which tells the regex whatever is found in this section and name it innnerArg, which gets used below in the output.

4 replies

Neo719Author
Inspiring
February 7, 2009
Hi Chris,

Sorry it has been a little while. Been to busy to return to this, but your code appears to work perfectly. Thanks!

Steven
Correct answer
January 24, 2009
You'll be adding your own edml file to do the translation. You should just use the ones in that folder as an example. Without testing the code it, my guess is it should look something like:

<participant name="transDynDataMyFormat">
<translator priority=400>
<searchPatterns>
<searchPattern><![CDATA[echo]]></searchPattern>
<searchPattern><![CDATA[addslashes]]></searchPattern>
<searchPattern paramNames="innerArg"><![CDATA[/\s*php\s*echo\s*addslashes\(htmlentities\(([^\r\n]*)\)\);?\s*/i]]></searchPattern>
</searchPatterns>
<translations>
<translation whereToSearch="directive" translationType="dynamic data">
<openTag>MM_DYNAMIC_CONTENT</openTag>
<display><![CDATA[{@@innerArg@@}]]></display>
<closeTag>MM_DYNAMIC_CONTENT</closeTag>
</translation>
<translation whereToSearch="tag+INPUT" limitSearch="attribute+VALUE" translationType="dynamic data">
<attributes>
<attribute><![CDATA[mmTranslatedValueDynValue="VALUE={@@rinnerArg@@}"]]></attribute>
</attributes>
</translation>
</translations>
</translator>
</participant>


I think the only tricky part is the paramNames on the search pattern just name the paren() matches from the regex. You'll see I added an extra () instead the call the htmlentities which tells the regex whatever is found in this section and name it innnerArg, which gets used below in the output.
Neo719Author
Inspiring
January 23, 2009
Thanks for the input. I have not messed with the EDML files so I will do a little research in the API.

This is a different extension from anything I have previously done. Any advice on how to do it in a way that does not involve editing the core/default dreamweaver files would be much appreciated.

I assume the way I have done this would not be considered the "proper" way to accomplish the task.

Thanks again...
Chris Bank - Express Dev
Participating Frequently
January 23, 2009
Try creating a translator edml file and see if that works. Look at the ones in "Configuration\Translators\PHP_MySQL" and it should do what you want.