I've made a structure to control several items on the page as a global element. I now want a related links object on that page to display across the entire site. The issue is, I think, that the "Indstillinger" page is a direct redirect to the "Forside" page below it. ( See here for a screenshot of the structure )
I've made the entire thing with the basic built-in code and macros - which works when I visualize it, but not in the template. So how do I modify the xslt to pull the data in the template?
<xsl:paramname="currentPage"/> <!-- Input the related links property alias here --> <!-- selectMenu, is the alias of the Related Links property --> <xsl:variablename="propertyAlias"select="string('selectMenu')"/> <xsl:templatematch="/">
<!-- The fun starts here --> <ul> <xsl:for-eachselect="$currentPage/* [name() = $propertyAlias and not(@isDoc)]/links/link"> <li> <xsl:elementname="a"> <xsl:iftest="./@newwindow = '1'"> <xsl:attributename="target">_blank</xsl:attribute> </xsl:if> <xsl:choose> <xsl:whentest="./@type = 'external'"> <xsl:attributename="href"> <xsl:value-ofselect="./@link"/> </xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:attributename="href"> <xsl:value-ofselect="umbraco.library:NiceUrl(./@link)"/> </xsl:attribute> </xsl:otherwise> </xsl:choose> <xsl:value-ofselect="./@title"/> </xsl:element> </li> </xsl:for-each> </ul>
<!-- Live Editing support for related links. --> <xsl:value-ofselect="umbraco.library:Item($currentPage/@id,$propertyAlias,'')"/>
</xsl:template>
</xsl:stylesheet>
Sorry if this seems like a totally stupid and silly question.. :S
The issue is that your for-each selector is selecting the related links from the current page. Depending on your exact requirement (I'm reading your description in 2 possible ways), you can do one of the following:
To select from the parent document of the current page, change your for-each to this:
<xsl:for-eachselect="$currentPage/../* [name() = $propertyAlias and not(@isDoc)]/links/link">
All I've done here is add ../ to select the data from the parent node
If you want to use a global setting for every page in your site use this:
<xsl:for-eachselect="umbraco.library:GetXmlNodeById(1065)/* [name() = $propertyAlias and not(@isDoc)]/links/link">
In this case, you should changed the 1065 to be the id of the page you want to retreive the data from. You can get this id by hovering the mouse over the node in the content tree and reading the id from the status bar of the browser.
get data from parent related links
I've made a structure to control several items on the page as a global element. I now want a related links object on that page to display across the entire site. The issue is, I think, that the "Indstillinger" page is a direct redirect to the "Forside" page below it. ( See here for a screenshot of the structure )
I've made the entire thing with the basic built-in code and macros - which works when I visualize it, but not in the template. So how do I modify the xslt to pull the data in the template?
<?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<!-- Input the related links property alias here -->
<!-- selectMenu, is the alias of the Related Links property -->
<xsl:variable name="propertyAlias" select="string('selectMenu')"/>
<xsl:template match="/">
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$currentPage/* [name() = $propertyAlias and not(@isDoc)]/links/link">
<li>
<xsl:element name="a">
<xsl:if test="./@newwindow = '1'">
<xsl:attribute name="target">_blank</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="./@type = 'external'">
<xsl:attribute name="href">
<xsl:value-of select="./@link"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="./@title"/>
</xsl:element>
</li>
</xsl:for-each>
</ul>
<!-- Live Editing support for related links. -->
<xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />
</xsl:template>
</xsl:stylesheet>
Sorry if this seems like a totally stupid and silly question.. :S
There's no such thing as a silly question.
The issue is that your for-each selector is selecting the related links from the current page. Depending on your exact requirement (I'm reading your description in 2 possible ways), you can do one of the following:
To select from the parent document of the current page, change your for-each to this:
<xsl:for-eachselect="$currentPage/../* [name() = $propertyAlias and not(@isDoc)]/links/link">
All I've done here is add ../ to select the data from the parent node
If you want to use a global setting for every page in your site use this:
<xsl:for-eachselect="umbraco.library:GetXmlNodeById(1065)/* [name() = $propertyAlias and not(@isDoc)]/links/link">
In this case, you should changed the 1065 to be the id of the page you want to retreive the data from. You can get this id by hovering the mouse over the node in the content tree and reading the id from the status bar of the browser.
HTH
Tom
Thank you for your help Tom, it's greatly appreciated!
Or to use the home ralated link content, you can use this:
So you don't have to use a number, easier for multiple language structure.
is working on a reply...