The code below just doesn't work as expected, perhaps someone could point me in the right direction. What I have is a contacts section that has a link to a another section of the website. The plan is to show a quick contact that changes depending on what section of the website you are looking at. If there is not link then a general (high level) quick contact is shown.
The problem with my code below is that when both conditions test true, both contacts are shown! How do I get around that problem, how do I get the code to evaluate to the last/second choice if both are true.
The heading of my post is totally wrong - I was going to ask a question about something else but ended up not doing it. The funny thing is that when I tried to edit it to be more inline with my post I got the following error from this website: Error parsing XSLT file: \xslt\forum-commentsList.xslt.
This sounds a bit like a problem that's usually solved using a "recursive property" in Umbraco, which you can do in a couple of ways - basically, your document will have a contact property which is defined as a Content Picker (or really any other type that store a content ID) - you can set this on all pages or you can set it only on some pages which would then be used for all descendants with no value set. The way to grab that value from XSLT is like this:
<xsl:template name="getContact">
<!-- Grab the nearest ancestor that has a value in the contact property -->
<xsl:variable name="contactId" select="$currentPage/ancestor-or-self::*[normalize-space(contact)][1]/contact" />
<!-- Grab the actual Contact node that was referenced -->
<xsl:variable name="contactNode" select="umbraco.library:GetXmlNodeById($contactId)" />
<!-- Print values from the Contact -->
<xsl:value-of select="$contactNode/fullName" />
<xsl:value-of select="$contactNode/email" />
<!-- etc. -->
</xsl:template>
Show parent node details in all subnodes
Hi all,
The code below just doesn't work as expected, perhaps someone could point me in the right direction. What I have is a contacts section that has a link to a another section of the website. The plan is to show a quick contact that changes depending on what section of the website you are looking at. If there is not link then a general (high level) quick contact is shown.
The problem with my code below is that when both conditions test true, both contacts are shown! How do I get around that problem, how do I get the code to evaluate to the last/second choice if both are true.
I hope this makes sense! ^^
<xsl:template name="getContact">
<xsl:variable name="referenceNode" select="umbraco.library:GetXmlNodeById(test)"/>
<xsl:choose>
<xsl:when test="$referenceNode/@id = $currentPage/ancestor-or-self::*[@level=2]/@id">
<xsl:call-template name="contactDetails"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$referenceNode/@id = $currentPage/ancestor-or-self::*[@level=$level]/@id">
<xsl:call-template name="contactDetails"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Thanks
K.
The heading of my post is totally wrong - I was going to ask a question about something else but ended up not doing it. The funny thing is that when I tried to edit it to be more inline with my post I got the following error from this website: Error parsing XSLT file: \xslt\forum-commentsList.xslt.
The story of my life ;-)
Hi Kirsten - welcome to the forum!
This sounds a bit like a problem that's usually solved using a "recursive property" in Umbraco, which you can do in a couple of ways - basically, your document will have a contact property which is defined as a Content Picker (or really any other type that store a content ID) - you can set this on all pages or you can set it only on some pages which would then be used for all descendants with no value set. The way to grab that value from XSLT is like this:
Hope that's kind of what you were after ...
/Chriztian
Thanks for your help!
kirsten.
is working on a reply...