Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.
-
mydev123 #1
Custom translator has problem with (InDreamweaver 8)
Hi,
I'm having trouble with my custom translator that works correctly in DW MX
2004, but behaves differently in DW 8. I've provided a simplified version of
my translator below (along with a sample test *.htm file). Thanks in advance
for any help!
This simple translator takes my custom body tag:
<custombody>
and replaces it with an ordinary body tag with green background:
<body bgcolor="#00FF00" style="background-color:#00FF00">
It also translates the closing tag. In DW MX 2004, I can open the page and
the background color appears green as expected. However in DW 8, when I open
the page the background color is just plain white. If I make a change to the
text (in Code View) and select Refresh, the background correctly turns green.
So it's as though the translation fails when the file is opened, but works
correctly upon refresh.
Something to note is that my test *.htm file has a table cell containing only
an . If I remove the cell containing the , the translation works
correctly (I can see the green background just after opening the page). I
don't know why the non breaking space would cause a problem, though.
Here is my test *.htm file:
-----------------------------------------------
<html>
<custombody>
<table>
<tr><td>
this is the first cell
</td></tr>
<tr><td>
</td></tr>
<tr><td>
this is the last cell
</td></tr>
</table>
</custombody>
</html>
-----------------------------------------------
And here is my translator file:
-----------------------------------------------
<html>
<head>
<title>Custom Body Tag</title>
<meta http-equiv="Content-Type" content="text/html; charset=">
<script language="JavaScript"
src="../Shared/MM/Scripts/Class/FileClass.js"></script>
<script language="JavaScript">
function getTranslatorInfo()
{
returnArray = new Array( 6 );
returnArray[ 0 ] = "CUSTOM_BODY_TAG"; // translatorClass
returnArray[ 1 ] = "Custom Body Tags"; // title
returnArray[ 2 ] = "0"; // nExtensions
returnArray[ 3 ] = "1"; // nRegExps
returnArray[ 4 ] = "<custombody"; // regExps
returnArray[ 5 ] = "byString"; // runDefault
return returnArray;
}
function translateMarkup( docName, siteRoot, docContent )
{
var x = convert( docName, docContent);
// File for debugging
DWfile.write( docName + '.trans', x );
return x;
}
function convert( docName, docContent)
{
var tag_start, tag_end, output;
output = "";
tag_start = docContent.indexOf( '<custombody' );
tag_end = docContent.indexOf( '</custombody' );
if ( tag_start == -1 ) return docContent;
// substring() returns up to but not including the end position
output += docContent.substring( 0, tag_start );
output += '<MM:BeginLock translatorClass="CUSTOM_BODY_TAG" type="mvt"
depFiles="" orig="%3Ccustombody%3E">';
output += '<body bgcolor="#00FF00" style="background-color:#00FF00">';
output += '<MM:EndLock>';
output += docContent.substring( tag_start+12, tag_end );
output += '<MM:BeginLock translatorClass="CUSTOM_BODY_TAG" type="mvt"
depFiles="" orig="%3C/custombody%3E">';
output += '</body>';
output += '<MM:EndLock>';
output += docContent.substring( tag_end+13, docContent.length );
return output;
}
</script>
</head>
<body>
</body>
</html>
-----------------------------------------------
Here is my *.mxi file:
-----------------------------------------------
<macromedia-extension
name="Custom Body Tag"
version="1.0.0"
requires-restart="true"
type="Suite">
<author name="TBD" />
<products>
<product name="Dreamweaver" version="7" primary="true" />
</products>
<description><![CDATA[This extension provides....]]></description>
<license-agreement>
<![CDATA[SAMPLE THIRD PARTY LICENSE TEXT:<br>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut
wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
lobortis nisl ut aliquip ex ea commodo consequat.]]>
</license-agreement>
<files>
<file source="CustomBody_Trans.htm"
destination="$dreamweaver/configuration/translators" />
</files>
<ui-access>
<![CDATA[This extension provides a custom property inspector...]]>
</ui-access>
</macromedia-extension>
-----------------------------------------------
mydev123 Guest
-
Extension Manager CS4 not installing extensions inDreamweaver CS4
Just installed CS4 Design Premium. Now i want to install some extensions to Dreamweaver. When I click on the extension to install it I get a... -
ColdFusion Login Wizard: How do you access this inDreamweaver CS3
The 'ColdFusion MX 7 Extensions' (CFMXDreamWeaverExtensions.mxp) could be installed for 'Dreamweaver MX 2004' using the 'Adobe Extension Manager'.... -
Problems when Creating Pages from Templates inDreamweaver 8
When creating new pages from templates in Dreamweaver 8(Ver 8.0.2). The full path for images is not created i.e. in template the code is <img... -
EditTextOnly.htm/translator problem
I have the following message when one of our users tries to open attempts unsucessfully to log in: "The Following translators were not loaded due... -
What does mean
Newbie here. What does   mean in code? -
Randy Edmunds #2
Re: Custom translator has problem with (In Dreamweaver 8)
Take a look in the "Server Model SSI.htm" translator. Search for
"debugTranslator" and you'll find a simple mechanism for looking at the
what the text of your page looks like "before" and "after" translation.
Hope this helps,
Randy
> I'm having trouble with my custom translator that works correctly in DW MX
> 2004, but behaves differently in DW 8...Randy Edmunds Guest
-
mydev123 #3
Re: Custom translator has problem with (InDreamweaver 8)
Hi Randy,
I appreciate your help. Per your suggestion, I've played with DWfile.write()
to see what the code looks like before and after translation. Both of my
beginning and end <custombody> tags look correct to me. That is:
<custombody>
Is translated to the following when I open my test file:
<MM:BeginLock translatorClass="CUSTOM_BODY_TAG" type="custombody" depFiles=""
orig="%3Ccustombody%3E">
<body bgcolor="#00FF00" style="background-color:#00FF00">
<MM:EndLock>
And the close tag:
</custombody>
Is translated to:
<MM:BeginLock translatorClass="CUSTOM_BODY_TAG" type="custombody" depFiles=""
orig="%3C/custombody%3E">
</body>
<MM:EndLock>
I say it looks correct because I also installed the example "<kent>" tag
translator, and my translated code looks similar as far as the BeginLock and
Endlock. And I did use a hex editor to make sure there weren't any strange
white characters and that carriage-returns/line feeds are correct.
I did notice that after I edit the test HTML in code view, and select Refresh,
the translation is run again. This time the translated code shows some
automatic formatting where Dreamweaver has moved the up to the same line
as the open <TD> tag. That's the only difference I see.
Do you have any other suggestions? Would you know where I can find an example
translator that works on tags pairs like <body> and </body>? The examples I've
seen are for single tags like the <kent> translator.
mydev123 Guest



Reply With Quote

