Search the FirstSpirit Knowledge Base
I'm using $CMS_RENDER(script:"...")$ in a page template in order to execute a script during generation. How do I access the currently generated page within the script, e.g. during preview generation? I tried context.getPage(), context.getGenerationContext().getPage() and some other accessors, but the result always seems to be null.
You can define additional parameters for you CMS_RENDER tag. See documentation.
So you could do something like this:
$CMS_RENDER(script:"yourscript", currentpage:#global.page)$
See here for more documentation on the #global object.
You can retrieve the parameters from the context object.
Thanks. That will do it. But just out of curiosity: I expected to find the page somewhere in the generation context without passing it as a parameter. What is the reason that it's not there?
If you're using your script within a template, you can also access the current page via the GenerationContext object. See here. So you could do a context.getGenerationContext(),getPage()