Yes, you're right - the issue is with your initial sectionNode variable, because it will only go up one level and then down again, but only selecting the final node if it's at level 1 - so you really need to specifically select that "Homepage Boxes" node.
I've assumed its alias is SectionBoxes (and that it's the only one of that kind at that level) - change the code accordingly so it works as it should. I took the liberty of changing a couple of other things too (purely for readability) - try to see if you can see for yourself what they are - and don't hesitate to ask why, if you're curious :-)
The link for more details is a content picker and I need the user to have the ability to choose any page and link to it but I fear the path to the page in my link currently /{@nodeName} writes the sction box node name to screen,
I also see the other changes you have made. This is a big help, many thanks, I have lots to learn with xslt!
(Again, you'll need to use the correct alias - I'm just taking a well-founded guess here :-)
You'll probably need to make sure that a page was selected, since NiceUrl() will fail horribly (just like the GetMedia() one does) if no ID is present...
Display Macro on all pages from Master Template
Hi all,
Just a quick one.
I have 3 boxes that contain content and an image that I want to show on all pages.
The boxes are updated from a node directly under the content node (see image)
The boxes show fine on the Homepage only. The Macro is in the Master Template.
I think My XSLT is wrong and is only selecting from a certain level. Here's my code:
I think the issue is in the variable select??
<xsl:variable name="sectionNode" select="$currentPage/parent::*/child::*[@level=1]"/>
<div id="sections">
<xsl:for-each select="$sectionNode/child::SectionBox">
<div>
<xsl:attribute name="class">section-<xsl:value-of select="@urlName"/></xsl:attribute>
<xsl:if test="current()/umbracoMediaFile != ''">
<xsl:variable name="umbracoMediaFile" select="umbraco.library:GetMedia(current()/umbracoMediaFile, 'false')" />
<div class="section-image">
<img src="{$umbracoMediaFile/umbracoFile}" width="276" height="144" alt="Homepage section image"/>
</div>
</xsl:if>
<h2><xsl:value-of select="contentBoxHeading"/></h2>
<xsl:value-of select="contentBoxText" disable-output-escaping="yes"/>
<a title="More details" class="more" >
<xsl:attribute name="href">/<xsl:value-of select="@nodeName"/></xsl:attribute>
More</a>
</div>
</xsl:for-each>
</div>
Hi Roger,
Yes, you're right - the issue is with your initial sectionNode variable, because it will only go up one level and then down again, but only selecting the final node if it's at level 1 - so you really need to specifically select that "Homepage Boxes" node.
I've assumed its alias is SectionBoxes (and that it's the only one of that kind at that level) - change the code accordingly so it works as it should. I took the liberty of changing a couple of other things too (purely for readability) - try to see if you can see for yourself what they are - and don't hesitate to ask why, if you're curious :-)
/Chriztian
Chriztian your a genius! Thank you!
Works perfect, just one slight query if I may?
The link for more details is a content picker and I need the user to have the ability to choose any page and link to it but I fear the path to the page in my link currently /{@nodeName} writes the sction box node name to screen,
I also see the other changes you have made. This is a big help, many thanks, I have lots to learn with xslt!
Hi Roger - thanks, you're welcome :-)
If you have a content picker, all you need to do is use the NiceUrl() extension to get the correct link, e.g.:
(Again, you'll need to use the correct alias - I'm just taking a well-founded guess here :-)
You'll probably need to make sure that a page was selected, since NiceUrl() will fail horribly (just like the GetMedia() one does) if no ID is present...
/Chriztian
Perfect!!
Thanks so much for the help again Chriztian.
All the best
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.