does generate the xml-node of the chosen page, but when I use the variable $boekentips to create a link, like $boekentips/id I get the following error message in the xslt-viewer:
"System.Xml.Xsl.XslLoadException: The variable or parameter 'id' is
either not defined or it is out of scope."
Can someone help me, all I need to do is create a link to the page that was chosen with the content picker.
I am not an xslt expert either, but have you tried your initial xslt by using $boekentips/@id instead of boekentips/@id to fill in your "id" variable. So, something like this:
Just to make sure I understand what you are trying to do:
1/ You have a "boekentips" property defined on your homepage document type only
2/ You want to display the "boekentips" link only on the homepage and you get an error on sub-pages OR 2 bis/ You want to display the boekentips link on all pages but it only works on the homepage.
Another question: Do you get anything else then "Error parsing XSLT file: \xslt\GetBoekentips.xslt". Maybe some indication on where it has problems?
problem with xslt
Hi, I guess I'll never be good at Xslt.
I created a property (boekentips) of datatype contentpicker.
Now in my xslt-file I just want to create a link to the page that the user has chosen with the content picker.
My xslt looks something like this:
<xsl:param name="currentPage"/>
<xsl:variable name="boekentips" select="umbraco.library:GetXmlNodeById($currentPage/boekentips)" />
<xsl:variable name="id" select="boekentips/@id" />
<xsl:template match="/">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:copy-of select="umbraco.library:NiceUrl($id)"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
But, as you one would imagine this doesn't work.
the line
<xsl:variable name="boekentips" select="umbraco.library:GetXmlNodeById($currentPage/boekentips)" />
does generate the xml-node of the chosen page, but when I use the variable $boekentips to create a link, like $boekentips/id I get the following error message in the xslt-viewer:
"System.Xml.Xsl.XslLoadException: The variable or parameter 'id' is either not defined or it is out of scope."
Can someone help me, all I need to do is create a link to the page that was chosen with the content picker.
Thanks for your help,
Anthony
I solved the problem partially, I changed my xslt-code to this:
<xsl:variable name="boekentips" select="umbraco.library:GetXmlNodeById($currentPage/boekentips)" />
<xsl:template match="/">
<a href="{umbraco.library:NiceUrl($boekentips/@id)}"><xsl:value-of select="$boekentips/@nodeName" /></a>
</xsl:template>
And this works, but only for the homepage. If I go to a page under the homepage I get this error:
Error parsing XSLT file: \xslt\GetBoekentips.xslt
Hi Anthony,
I am not an xslt expert either, but have you tried your initial xslt by using $boekentips/@id instead of boekentips/@id to fill in your "id" variable. So, something like this:
Hope this helps.
Cheers,
Michael.
Hi Anthony
Do you have the content picker on each page of your site or just the homepage?
If you've got it on every page try this:
/Kim A
Hi Michael,
I already solved the problem partially, my xslt-code looks like this now:
<xsl:variable name="boekentips" select="umbraco.library:GetXmlNodeById($currentPage/boekentips)" />
<xsl:template match="/">
<a href="{umbraco.library:NiceUrl($boekentips/@id)}"><xsl:value-of select="$boekentips/@nodeName" /></a>
</xsl:template>
The only problem I still have is that this only works on my homepage, the boekentips property is defined on the homepage document type.
But if I go to a page that is a child of the homepage I get the error:
Error parsing XSLT file: \xslt\GetBoekentips.xslt
Thanks for your help (again),
Anthony
@Kim: I only got the boekentips property defined on my homepage document type.
Thanks for your help,
Anthony
Hi Anthony,
Just to make sure I understand what you are trying to do:
1/ You have a "boekentips" property defined on your homepage document type only
2/ You want to display the "boekentips" link only on the homepage and you get an error on sub-pages
OR
2 bis/ You want to display the boekentips link on all pages but it only works on the homepage.
Another question: Do you get anything else then "Error parsing XSLT file: \xslt\GetBoekentips.xslt". Maybe some indication on where it has problems?
Cheers,
Michael.
Hi Michael,
it's 2 bis :)
I define the boekentips property on my homepage document type, but it should show on all child pages under my homepage.
I have adapted a little the code snippet of Kim by using an XPath axis, like this:
<xsl:template match="/">
<xsl:if test="ancestor-or-self::boekentips!=''">
<xsl:variable name="boekentips" select="umbraco.library:GetXmlNodeById($currentPage/boekentips)"/>
<a href="{umbraco.library:NiceUrl($currentPage/boekentips)}"><xsl:value-of select="$boekentips/@nodeName" /></a>
</xsl:if>
</xsl:template>
but it doesn't work
Hi Anthony,
It is in fact possible to identify the document type name by using the name() method. So maybe you might try something like this:
Hope this helps/works :-)
Cheers,
Michael.
Okay.
Let's say that your homepage is located on level 1, then you should be able to do like this:
Or you could also grab the homepage by it's document type like this (if the document type of the homepage is called Homepage):
<xsl:variable name="home" select="$currentPage/ancestor-or-self::Homepage" />
/Kim A
Hi Kim,
I tried your code example and it works, thanks a lot!
Anthony
I'm glad to hear that Anthony. You are very welcome.
/Kim A
is working on a reply...