I have a sidebar control where the user can add blocks to the sidebar with a heading and text. The sidebars show on the homepage but not on internal text pages. I think this is something to do with the level set in the XSLT but im not sure. Please can you help? Here is a breakdown of what I have:
Did you use the actual doctype alias for the SidebarControl?
The thing is, your sidebarNode variable actually selects all the level 1 nodes ("Stella Maris", "Sidebar Control" & "Slider Control") because the selector goes through currentPage and all its ancestors, selecting all of their children, then filtering by the level attribute.
The only reason the for-each grabs the right nodes is because you have no Sidebars documents as children of neither "Stella Maris" nor "Slider Control"...
It's not a big problem in this setup - but you're very likely to refer to this for another site maybe, and if you're on a big site, those kinds of selectors can get very slow and have sideeffects because of the amount of nodes that are really selected.
Help with XSLT to display content on all levels
Hi all,
I have a sidebar control where the user can add blocks to the sidebar with a heading and text.
The sidebars show on the homepage but not on internal text pages. I think this is something to do with the level set in the XSLT but im not sure. Please can you help?
Here is a breakdown of what I have:
The XSLT:
<xsl:variable name="sidebarNode" select="$currentPage/parent::*/child::*[@level=1]"/>
<xsl:for-each select="$sidebarNode/child::Sidebars">
<div class="hotspot">
<h4><xsl:value-of select="sidebarHeading" disable-output-escaping="yes"/></h4>
<img width="52" height="52" src="/images/icons/dezinerfolio/info.png" />
<xsl:value-of select="sidebarContent" disable-output-escaping="yes"/>
</div>
</xsl:for-each>
The content structure:
As I mentioned, the sidebars show on the homepage (Stella Maris node) but not on the internal pages
Any help is greatly appreciated
Thanks
Roger
To add: The Macro is in the Master Template
Hi Roger,
You should be able to always locate the right nodes using something like this:
/Chriztian
Hi Chriztian,
That didnt work unfortunately. No errors but the sidebars disappeared from the homepage.
Its just a development site at the moment so Im happy to give login details
Thank you very much for the help
Roger
Ah, i think I have it working.
I used my code but changed the variable to:
<xsl:variable name="sidebarNode" select="$currentPage/ancestor-or-self::*/child::*[@level=1]"/>
instead of
<xsl:variable name="sidebarNode" select="$currentPage/parent::*/child::*[@level=1]"/>
Many thanks :)
Hi Roger,
Did you use the actual doctype alias for the SidebarControl?
The thing is, your sidebarNode variable actually selects all the level 1 nodes ("Stella Maris", "Sidebar Control" & "Slider Control") because the selector goes through currentPage and all its ancestors, selecting all of their children, then filtering by the level attribute.
The only reason the for-each grabs the right nodes is because you have no Sidebars documents as children of neither "Stella Maris" nor "Slider Control"...
It's not a big problem in this setup - but you're very likely to refer to this for another site maybe, and if you're on a big site, those kinds of selectors can get very slow and have sideeffects because of the amount of nodes that are really selected.
/Chriztian
Ah I see, that makes sense.
I'll give that a go and see if it works
Many thanks for all the help
Roger
Hi chriztian,
I tried that but the sidebars failed to display on all pages again,
This code works:
<xsl:variable name="sidebarNode" select="$currentPage/ancestor-or-self::*/child::*[@level=1]"/>
<xsl:for-each select="$sidebarNode/child::Sidebars">
<div class="hotspot">
<h4><xsl:value-of select="sidebarHeading" disable-output-escaping="yes"/></h4>
<img width="52" height="52" src="/images/icons/dezinerfolio/info.png" />
<xsl:value-of select="sidebarContent" disable-output-escaping="yes"/>
</div>
</xsl:for-each>
Am i doing something wrong I wonder?
Roger
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.