Hi
I have a question to do with publishing and previewing. Is it possible to put some code in a template so when a page is previewed in the editor a piece of html content is shown but when it is published that code is not published but in its place a include tag to a piece of content is published instead (see below)?
Code in preview
<div id="englandoffer">
<a href="/coach/Destinations/wembley.cfm" target="_blank">
<img src="/coach_ims/teasers/offical_travel_partner.gif" alt="National Express - Wembley Stadium" width="300" height="141" border="0" />
</a>
</div>
Code when published
<div id="englandoffer">
<cfinclude template="/coach/inc/promo.cfm" />
</div>
Any suggestions.
I haven’t tried that myself, but one of my colleagues has.
You need to check for the context, so he used a variable “$sys.context” in the template binding, with a value of “$sys.params.sys_context(0)” (if I understand my notes correctly).
Something like this might work in your template:
<div id="englandoffer">
#if ($sys_context == "0")
<a href="/coach/Destinations/wembley.cfm" target="_blank">
<img src="/coach_ims/teasers/offical_travel_partner.gif" alt="National Express - Wembley Stadium" width="300" height="141" border="0" />
</a>
#else
<cfinclude template="/coach/inc/promo.cfm" />
#end
</div>
I use:
#if ($rx.asmhelper.getSingleParamValue($sys.params, “sys_context”) == “0”)
which is a bit more verbose (and probably unnecessary).
Cheers Guys, I give this a go.