Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1287 posts 2744 karma points
    Sep 08, 2010 @ 21:07
    Amir Khan
    0

    Get properties from parent pages with separator in between

    I have this snippet of code from the Get Meta Tags package, which is working great. For the title tag, I'd like it to traverse up and get all of the title tags of the pages above it, except the homepage and put a separator in between (| or - or :). I get how to look down from the current page, but am having trouble finding out how to go up and then ignore the top level...So the desired output would be like this: Current Page - Parent Page - Site Title

    Any help would be appreciated!

     

    <title><xsl:for-each select="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'title'])='')]">
      <xsl:sort select="position()" data-type="number" order="descending"/>
      <xsl:if test="position()=1">
        <xsl:value-of select="./data [@alias = 'title']" /> - Site Title Here
      </xsl:if>
      </xsl:for-each>
    </title>
  • Thomas Höhler 1237 posts 1709 karma points MVP
    Sep 08, 2010 @ 21:26
    Thomas Höhler
    0

    With

    <xsl:for-each select ="$currentPage/ancestor-or-self::node [@level &gt; 1]">

    you get all parent nodes starting with the current node but ending with the node on level 2 ("&gt;" = "greater than"). See http://umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcuts

    hth, Thomas

     

  • Amir Khan 1287 posts 2744 karma points
    Sep 08, 2010 @ 21:30
    Amir Khan
    0

    Hmm, That seems to just return the current node, also it returns nothing on the top node. I didn't realize before that it should show the top node title only when its the current page.

  • Amir Khan 1287 posts 2744 karma points
    Sep 08, 2010 @ 21:30
    Amir Khan
    0

    Hmm, That seems to just return the current node, also it returns nothing on the top node. I didn't realize before that it should show the top node title only when its the current page.

  • Amir Khan 1287 posts 2744 karma points
    Sep 08, 2010 @ 21:35
    Amir Khan
    0

    Actually that code on traverses up and shows the parent if the current page has children it seems? Something funny is going on with it, it almost seems to be arbitrarily showing the parents title field.

Please Sign in or register to post replies

Write your reply to:

Draft