filter in template to distinguish between preview and publish

I would like to have some kind of binding variable in my template so I can make a decision whether the request is coming from the publish or for preview.

I saw somewhere you can setup this filter and then you can have the if condition block in your templates to handle differently preview and publish.

Can someone help me to figure out this?


You could take a look at this thread:

I implemented a binding that checked $sys.params.sys_itemfilter, so that the binding is based on the Item Filter selected in the content list and passed as a parameter for the assembly request. There are other attributes of $sys.params, such as sys_siteid and sys_context - maybe there is something there that work for your purpose (sys_context seems the most likely). There’s a list of the available parameters on page 410 of the Rhythmyx 6.5.2 Implementation Guide.

If you would like to render different markup in your templates depending on whether the item is being published or a user is using the active assembly preview you can:

  1. Create a binding, $isPublish = $tools.number.toNumber($tools.list.get($sys.params.get(‘sys_context’),0)) > 0
  2. In the template add the code:
    #if( $isPublish)
    Output markup for published page
    Output markup for active assembly preview

Technically you do not need a binding, but it is cleaner in the markup that way.

I’ve also found that the boolean value $sys.activeAssembly is helpful.

I usually use, in my template bindings:
$isPreview = $sys.activeAssembly || $sys.assemblyItem.context == 0

Is there any way to see this in the global template rather than the individual templates?