Skip to main content
November 3, 2007
Question

Create a PHP Translator

  • November 3, 2007
  • 1 reply
  • 1031 views
I would like to create a Dreamweaver Translator which will translater specific PHP tags: For example:

<?php include 'test.php' ?>

If the tag is equal to the above I want to display something besides the normal PHP image that dreamweaver displays. I wrote a translator and in the getTranslatorInfo() function I used the expression "<?php" but when the translator loads I get an error

The following translators were not loaded due to errors:
myphp.htm has information duplicated by another translator.

So i gather that the dreamweaver transator for <?php conflicts with mine. conSo how do i get around this?
This topic has been closed for replies.

1 reply

Inspiring
November 3, 2007
"ryanmhuc" <webforumsuser@macromedia.com> wrote in message
news:fghbjn$hlq$1@forums.macromedia.com...
> I would like to create a Dreamweaver Translator which will translater
> specific
> PHP tags: For example:
>
> <?php include 'test.php' ?>
>
> If the tag is equal to the above I want to display something besides the
> normal PHP image that dreamweaver displays. I wrote a translator and in
> the
> getTranslatorInfo() function I used the expression "<?php" but when the
> translator loads I get an error
>
> The following translators were not loaded due to errors:
> myphp.htm has information duplicated by another translator.
>
> So i gather that the dreamweaver transator for <?php conflicts with mine.
> conSo how do i get around this?


Without more information, I would suggest that you create a more specific
pattern and since it's PHP code I would also suggest to limit the
translation to PHP Servermodel related files for speed.
You can also create a serverbehavior for your code first, and add a
translation in the EDML, this way you can use the more specific matching
methods like whereToSearch and quickSearch

For example: here's a snippet from my custom Repeat region DWMX extension
(it's ASP but you'll get the idea)

<participant name="VSS_Repeat_Checkout_begin">
<translator>
<searchPatterns whereToSearch="directive">
<searchPattern paramNames="loopName,rsName" isOptional="false"
limitSearch="all"><![CDATA[/Dim ([^\r\n]*?)_index(?:\r\n|\r(?!\n)|\n)[
\t]*[^\r\n]*?_index = 0(?:\r\n|\r(?!\n)|\n)[ \t]*For Each [^\r\n]*? in
([^\r\n]*?)\.Checkouts ' repeat Checkouts(?:\r\n|\r(?!\n)|\n)[
\t]*[^\r\n]*?_index = [^\r\n]*?_index \+
1(?=\r\n|\r|\n|%>)/i]]></searchPattern>
<searchPattern requiredLocation="trailing"><![CDATA[/Next ' repeat
Checkouts ([^\r\n]*?) in
([^\r\n]*?)\.Checkouts(?=\r\n|\r|\n|%>)/i]]></searchPattern>
</searchPatterns>
<translations>
<translation whereToSearch="directive" translationType="tabbed region
start">
<openTag>MM_REPEATEDREGION</openTag>
<attributes>
<attribute><![CDATA[NAME="@@loopName@@"]]></attribute>
<attribute><![CDATA[SOURCE="@@rsName@@"]]></attribute>
</attributes>
<display>MM.LABEL_RepeatTabbedOutlineLabel</display>
</translation>
</translations>
</translator>
</participant>

--
Joris van Lier

November 3, 2007
If i undertand you correctly you suggestioning to create a unique tag. But that will not accomplish what i'm looking for. I do not need a work around i need the solution. I know its possible to intercept built in tags like the PHP tags I just don't know how. Please if anyone knows lend a hand.