What I want to do for each piece of content is bring in the node name within a h4 TAG as well as the content, this is my markup, I can't seem to bring back this variable within the XSLT, could anybody help me with this?
However in the sample code you have above there is a variable created in the template that has the node specified by the $currentId which is passed through and assigned to the $currentNode variable so you could either do the same has been added to have a variable for current content
I haven't tested this but I think this should work for you
For clarity I've listed here then what the whole file might look like in two examples one where you assign the extra variable and one where you just use the selectors directly
Creating reusable content
Hi,
I am using this fantastic piece of code http://our.umbraco.org/wiki/how-tos/creating-reusable-content to create small nuggest of resuable conte across my website, in most part it works fine.
What I want to do for each piece of content is bring in the node name within a h4 TAG as well as the content, this is my markup, I can't seem to bring back this variable within the XSLT, could anybody help me with this?
Kind regards
<xsl:template name="Render">
<xsl:param name="currentId" />
<xsl:if test="string($currentId) != ''">
<xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById($currentId)" />
<xsl:variable name="currentContent" select="$currentNode/moduleContent" />
<xsl:element name="div">
<xsl:attribute name="class">panel</xsl:attribute>
<h4><xsl:value-of select="@nodeName"/></h4>
<p><xsl:value-of select="$currentContent" disable-output-escaping="yes" /></p>
</xsl:element>
</xsl:if>
</xsl:template>
Where you have
<h4><xsl:value-of select="@nodeName"/></h4>
you need to prefix that with the variable this @nodeName is coming from
So for example if it were the default to show the current page there is the standard variable always available that you would use
<xsl:variable name="currentContent" select="$currentNode/moduleContent" />
where presumably moduleContent is the name of a document property that you have
so the equivalent would be to add beneath this variable
<xsl:variable name="currentHeading" select="$currentNode/@nodeName" />
and then
I haven't tested this but I think this should work for you
For clarity I've listed here then what the whole file might look like in two examples one where you assign the extra variable and one where you just use the selectors directly
With extra variable:
Or just using the selector directly:
HTH :)
Hi John,
Thanks very much for the advice, seems so simple when you know how. Works great thank you again.
Cheers
Nick
]
you're very very welcome :)
please remember to mark the solution (tick the green arrow)
and hope you have many many happy fun filled hours with Umbraco
(it is very very good!)
is working on a reply...