I'm trying to get a parent-item in one of my Macros but I'm not getting any results.
I tried the code below to get the id of the item but it doesn't result anything <xsl:value-of select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'ParcaeTextpage1column']/@id" />
I also tried another variant like <xsl:value-of select="$currentPage/ancestor-or-self::node [@nodeName = 'Parcae']/@id" /> but that also doesn't return anything.
The $currentPage returns the id that I expect, but that is all that I can get to work.
Hm, have you removed the 'ancestor-or-self::' bit intentionally? The code above will only generate the id if you are on the page with the content node name of 'SiteSettings', which I'm pretty sure is not even associated with a page template.
There is no @nodeTypeAlias anymore since the alias is now the node name itself instead of the generic node. So the XML representation of the node you are looking for should be something like this:
<ParcaeTextpage1column isDoc="1" ...>
The case of the SiteSettings node seems to be different. Is it actually a parent of the current page or does it sit somewhere ales on the site?
In the last case try something like
<xsl:value-of select="$currentPage/ancestor-or-self::root/descendant::*[@isDoc and name() = 'SiteSettings']" />
assumeing 'SiteSettings' is the doc type name, if it is actually the name of the node then use @nodeName.
The SiteSettings is a different item that I'm trying to get. It is a child-item of $currentPage so using the ancestor-or-self::root/descendant is a bit overkill. That is why I thought this should work <xsl:value-of select="$currentPage/*[@isDoc and @nodeName = 'SiteSettings']/@id" /> And i'm using the name of the node
I tried the count, for some reason my "SiteSettings" item is not seen as a document by @isDoc. Or maybe not seen at all, allthough it is published.
I've added another item based on a textpage and that item increases the count with 1. The strange thing is that my SiteSettings items is not seen. I just removed the old one and created a new item and assigned a template to it and then it is seen again....
Issue with ancestor-or-self in 4.5.1
I'm trying to get a parent-item in one of my Macros but I'm not getting any results.
I tried the code below to get the id of the item but it doesn't result anything
<xsl:value-of select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'ParcaeTextpage1column']/@id" />
I also tried another variant like
<xsl:value-of select="$currentPage/ancestor-or-self::node [@nodeName = 'Parcae']/@id" />
but that also doesn't return anything.
The $currentPage returns the id that I expect, but that is all that I can get to work.
hope that someone can help me with that
I think ::node should be replaced with ::* in the new schema, and nodeTypeAlias is now name()
Not tested, but I think this would work:
<xsl:value-of select="$currentPage/ancestor-or-self::* [@isDoc and name() = 'ParcaeTextpage1column']/@id" />
See http://our.umbraco.org/wiki/reference/xslt/45-xml-schema and http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema
Double post, see http://our.umbraco.org/forum/developers/xslt/12535-Issue-with-ancestor-or-self-in-451
Thanks, replacing the ::node with ::* did the trick.
I thought that this should work too, but it doesn't.... the new XML-schema gets me confused
<xsl:value-of select="$currentPage/*[@isDoc and @nodeName = 'SiteSettings']/@id" />
Hm, have you removed the 'ancestor-or-self::' bit intentionally? The code above will only generate the id if you are on the page with the content node name of 'SiteSettings', which I'm pretty sure is not even associated with a page template.
There is no @nodeTypeAlias anymore since the alias is now the node name itself instead of the generic node. So the XML representation of the node you are looking for should be something like this:
<ParcaeTextpage1column isDoc="1" ...>
The case of the SiteSettings node seems to be different. Is it actually a parent of the current page or does it sit somewhere ales on the site?
In the last case try something like
<xsl:value-of select="$currentPage/ancestor-or-self::root/descendant::*[@isDoc and name() = 'SiteSettings']" />
assumeing 'SiteSettings' is the doc type name, if it is actually the name of the node then use @nodeName.
Hope that helps,
Sascha
Sorry, I was a bit incomplete with my last post.
The SiteSettings is a different item that I'm trying to get. It is a child-item of $currentPage so using the ancestor-or-self::root/descendant is a bit overkill. That is why I thought this should work <xsl:value-of select="$currentPage/*[@isDoc and @nodeName = 'SiteSettings']/@id" />
And i'm using the name of the node
Yup, that is indeed a bit overkill. ;)
I'm a bit stumped as well as I've thought that would work. What happens if you do the following:
no. of child nodes: <xsl:value-of select="count($currentPage/*[@isDoc])" /><br /><br />
Cheers,
Sascha
I tried the count, for some reason my "SiteSettings" item is not seen as a document by @isDoc. Or maybe not seen at all, allthough it is published.
I've added another item based on a textpage and that item increases the count with 1. The strange thing is that my SiteSettings items is not seen. I just removed the old one and created a new item and assigned a template to it and then it is seen again....
Hm, very odd indeed! Does that mean your
<xsl:value-of select="$currentPage/*[@isDoc and @nodeName = 'SiteSettings']/@id" />
is now working?
After deleting and recreating the SiteSettings item the statement now works. Thanks!
is working on a reply...