Sorry, I'm a little confused. Where exactly are you wanting to get the parent page? Is it inside the second for-each loop where you right out the link? If so just replace $currentPage with "." to indicate the current node in the for-each loop
Minor correction - the reason they don't include the surrounding XML is because they're fetched with the <xsl:copy-of /> instruction - the GetXmlNodeById() function returns a pointer to the node within the complete XML, but the copy-of destroys that relationship.
Good call on using @parentID attribute to retrieve them!
Getting the parent for a url
Hi im using this xslt to pick som products and show their data.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="preNodes">
<xsl:variable name="relatedContent" select="$currentPage/productPicker" />
<xsl:variable name="nodeIds" select="umbraco.library:Split($relatedContent, ',')" />
<xsl:for-each select="$nodeIds/value">
<xsl:copy-of select="umbraco.library:GetXmlNodeById(.)"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="nodes" select="msxml:node-set($preNodes)/*[@isDoc]" />
<xsl:if test="count($nodes) > 0">
<ul class="productList">
<xsl:for-each select="$nodes">
<li class="two left marginTop10px">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="$currentPage/preceding::node/@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
This works fine but in the url I need to get the parent url instead of the current.
<xsl:value-of select="$currentPage/preceding::node/@nodeName"/>
I tried this but it didn't work. Any ideas how to get the parent for the selected page and not the selected one?
Thanks / Niklas
This should work:
-Tom
Hi Tom
This only gets me the current page parent, not the one I have selected using the picker.
Example:
Page showing the macro: /parent/pageShowingMacro
The macro fetches pages selected with a picker
/productPageParent/productpage
I want to get the productPageParent not the parent.
Regards / Niklas
Sorry, I'm a little confused. Where exactly are you wanting to get the parent page? Is it inside the second for-each loop where you right out the link? If so just replace $currentPage with "." to indicate the current node in the for-each loop
Exactly. When I put your code in the second for each I don't get anything at all.
Ok, I see the issue, the nodes are generated from umbraco.library:GetXmlNodeById which doesnt include the parent XML
But you can use the @parentID attribute to retrieve it:
That should do it!
Hi,
Minor correction - the reason they don't include the surrounding XML is because they're fetched with the <xsl:copy-of /> instruction - the GetXmlNodeById() function returns a pointer to the node within the complete XML, but the copy-of destroys that relationship.
Good call on using @parentID attribute to retrieve them!
/Chriztian
Works fine, thanks!
is working on a reply...