I'm using umbraco.library.renderTemplate to render boxes / widgets on a page. So from frontpage I have a macro that does the following
For each box renderTemplate(boxid)
The above is cool. It allows renderTemplate to run in the context of the box as being the currentPage. But say I put a macro on the template. How can it get access to the currentPage - and still keep the box context too? This would allow my boxes to behave differently on each page.
For uComponents RenderTemplate control (which is effectively the same as what you are doing), we have a custom property for passing through values from the current page to the "widget" pages.
It uses "HttpContext.Current.Items" to store the data/value.
The template and any macro defined in the template will be able to access both the box context (currentPage) or the page context using contextPageId. Xslt example:
umbraco.library.renderTemplate
Hi all,
I'm using umbraco.library.renderTemplate to render boxes / widgets on a page. So from frontpage I have a macro that does the following
For each box
renderTemplate(boxid)
The above is cool. It allows renderTemplate to run in the context of the box as being the currentPage. But say I put a macro on the template. How can it get access to the currentPage - and still keep the box context too? This would allow my boxes to behave differently on each page.
Or another approach working on content boxes?
Best
Jesper
Hi Jesper,
For uComponents RenderTemplate control (which is effectively the same as what you are doing), we have a custom property for passing through values from the current page to the "widget" pages.
It uses "HttpContext.Current.Items" to store the data/value.
Cheers, Lee.
Thx lee,
This looks cool - unfortunately I'm in a xslt loop :-)
Also the template could contain an xslt macro (could change)
Best
J
Hi Jesper,
There is an XSLT extension for getting the value...
... but couldn't find anything that could set the value. :-(
Cheers, Lee.
Found a way :-)
The Macro RenderAllBoxes sets the current PageId in session before looping through the boxes. Like this:
The template and any macro defined in the template will be able to access both the box context (currentPage) or the page context using contextPageId. Xslt example:
<xsl:variable name="contextId" select="umbraco.library:Session('ContextPageId')"/> <xsl:variable name="contextPage" select="umbraco.library:GetXmlNodeById($contextId)"/> Box context nodeName: <xsl:value-of select="$currentPage/@nodeName"/> <br/>Page "the real" nodeName: <xsl:value-of select="$contextPage/@nodeName"/>
Now I have "selfcontained" box renderings that have access to the page context allowing me to let the box rendering react on both.
Best
Jesper
is working on a reply...