Insert ColdFusion/PHP/JS/... code snippet in a content item ANYWHERE the user wants

The ideal way for us to insert ColdFusion code snippet like
<cfif condition is true>
<cfoutput>#mymessage#</cfoutput>
</cfif>
is to directly access the “Code” tab of EditLive editor and insert the code wherever we want

But the reality is EditLive uses strict DHTML validator via http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd, which does NOT know those ColdFusion tags and will spit out the following error when saving the content item

An exception occurred while processing the “PSXdTextCleanup” extension: com.percussion.extension.PSExtensionProcessingException: Errors encoutered in Tidyline 1 column 1 - Error: <cfif>, <cfoutput> is not recognized!
This document has errors that must be fixed before using HTML Tidy to generate a tidied up version.

Any idea how to insert ColdFusion/PHP/JSP/Javascript or any other code snippet anywhere users want in a content item?

Thanks, -Hua

You could make a coldfusion content type with one large text input field, this content type would have one snippet template and users could inline template link the code snippets in ephox like any other template. This assumes that the page is already being published out as a .cfm page but you could have logic to determine which extension to use. This approach might also help with code reuse which could be an added bonus.

Thanks pilotstevek for your quick response!

I am NOT sure what you mean by “inline template link the code snippets”. This is what I did before. We have content type named “wwwCFCode” which has a TEXTAREA field for the CF code snippet. I then created a snippet template called “wwwSnippetCFCode” which does nothing more than outputing the TEXTAREA field in content type “wwwCFCode”. NOTE: sys_TEXTAREA field is NOT restricted by the http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd validation rule, only EditLive rich editor does. I then created a content item with EditLive editor, and inserted my wwwCFCode content item (which has one line CF code <output>#mymsg#</output>) via snippet template “wwwSnippetCFCode” as an inline variant by clicking the button “Insert Rhythmyx Template”. When I tried to save the content item containing the inline variant, I got this error, which basically is the same error when inserting the CF code directly via the EditLive editor Code tab

<PSXLogErrorSet class=“Request preprocessing” host=“edit” port=“9992” protocol=“http” root=“/Rhythmyx” rxroot=“http://edit:9992/Rhythmyx”>

<Error id="0>
An error occurred while pre-processing the request submitted by the host (-not available-).

</Error>

<Error id=“1”>
An exception occurred while processing the “PSXdTextCleanup” extension: com.percussion.extension.PSExtensionProcessingException: Errors encoutered in Tidyline 155 column 18 - Error:
<cfoutput> is not recognized!
line 284 column 97 - Error: <cfoutpu> is not recognized!
line 285 column 94 - Error: <cfoutput> is not recognized!
line 286 column 82 - Error: <cfoutput> is not recognized!
line 287 column 76 - Error: <cfoutput> is not recognized!
line 288 column 85 - Error: <cfoutput> is not recognized!
line 289 column 85 - Error: <cfoutput> is not recognized!
This document has errors that must be fixed before
using HTML Tidy to generate a tidied up version.

The table summary attribute should be used to describe
the table structure. It is very helpful for people using
non-visual browsers. The scope and headers attributes for
table cells are useful for specifying which headers apply
to each table cell, enabling non-visual browsers to provide
a meaningful context for each cell.

For further advice on how to make your pages accessible
see “Accessibility Guidelines Working Group”. You may also want to try
http://www.cast.org/bobby/” which is a free Web-based
service for checking URLs for accessibility.

.

</Error>

</PSXLogErrorSet>

Have you tried adding the tag to the tidy.properties file? http://forum.percussion.com/showthread.php?754-Tidy-settings-don-t-work (rxW2Ktidy.properties)

This probably isn’t a long term solution (unless you want to maintain a large list of cf tags)…but just curious if you had…

You could also try adding a full page template to your CF content type and the snippet template would be changed to a one line cfinclude that points to the fullpage template that outputs the code.

This is what I finally decide to do:

Do NOT use EditLive Code tab or inline variant/template to insert CF/PHP/ASP/… code … EditLive+CMS always try to ‘fix’ your code

In our case most pages are HTML, only a handful have CF/JS/… embedded. I created a page template for each page that has specific CF/JS code embedded. In the content type I have a ‘template’ dropdown field populated with templates associated with that content type (using a XML app). The ‘template’ field is only visible to the developer role. Then I created a dispatch template to use the template the developer selects