Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martijn van der Put 44 posts 65 karma points
    Sep 09, 2010 @ 18:28
    Martijn van der Put
    0

    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

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Sep 09, 2010 @ 18:45
    Tom Fulton
    0

    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

  • Sascha Wolter 615 posts 1101 karma points
    Sep 09, 2010 @ 20:54
  • Martijn van der Put 44 posts 65 karma points
    Sep 09, 2010 @ 22:26
    Martijn van der Put
    0

    Thanks, replacing the ::node with ::* did the trick. 

  • Martijn van der Put 44 posts 65 karma points
    Sep 09, 2010 @ 23:35
    Martijn van der Put
    0

    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" />

  • Sascha Wolter 615 posts 1101 karma points
    Sep 09, 2010 @ 23:47
    Sascha Wolter
    0

    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

  • Martijn van der Put 44 posts 65 karma points
    Sep 09, 2010 @ 23:57
    Martijn van der Put
    0

    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

  • Sascha Wolter 615 posts 1101 karma points
    Sep 10, 2010 @ 00:09
    Sascha Wolter
    0

    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 />

    <xsl:for-each select="$currentPage/*[@isDoc]">
      position: <xsl:value-of select="position()" />,&nbsp;
      name: <xsl:value-of select="current()/@nodeName" /><br />
      <textarea style="width: 300px; height: 200px;">
        <xsl:copy-of select="current()" />
      </textarea><br />
    </xsl:for-each>

    Cheers,

    Sascha

  • Martijn van der Put 44 posts 65 karma points
    Sep 10, 2010 @ 00:26
    Martijn van der Put
    0

    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....

  • Sascha Wolter 615 posts 1101 karma points
    Sep 10, 2010 @ 00:41
    Sascha Wolter
    0

    Hm, very odd indeed! Does that mean your

    <xsl:value-of select="$currentPage/*[@isDoc and @nodeName = 'SiteSettings']/@id" />

    is now working?

  • Martijn van der Put 44 posts 65 karma points
    Sep 10, 2010 @ 01:12
    Martijn van der Put
    0

    After deleting and recreating the SiteSettings item the statement now works. Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft