Copied to clipboard

Flag this post as spam?

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


  • Eddie Foreman 215 posts 288 karma points
    Sep 27, 2010 @ 13:54
    Eddie Foreman
    0

    Display Link to Parent

    Hi All

    Looking for some help.  Have a products landing page, with a number of products sub pages.

    Products
    - product one
    - product two

    All product pages have a radio list data type to choose the type of product.  The xslt below lists all of the products,  but I cannot get it to show the parent link. The xslt is only used on the sub pages.

      <xsl:template match="/">
    <ul>
    <li>
    <xsl:variable name="preValueId" select="./@id" />
    <a href="#"><!-- needs to be href of parent page of all products-->
    <xsl:attribute name="class">selectDrop</xsl:attribute>
    <xsl:text>All Products</xsl:text><!-- should be parent nodeName -->
    </a>
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::node /node[data[@alias='productType']]">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:if test="$currentPage/ancestor-or-self::node/data[@alias='productType'] = ./@id">
    <xsl:attribute name="class">selectArea</xsl:attribute>
    </xsl:if>
    <xsl:if test="$currentPage/@id = current()/@id">
    <xsl:attribute name="class">select</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@nodeName"/>
    </a>
    </li>
    </xsl:for-each>
    </ul>
    </li>
    </ul>
    </xsl:template>

    Using Umbraco 4.0.4.2

    Thanks again

    Eddie

  • Rich Green 2246 posts 4006 karma points
    Sep 27, 2010 @ 14:44
    Rich Green
    0

    Hi Eddie,

    At a guess, this should work

    <xsl:template match="/">
        <ul>
          <li>
            <a href="{umbraco.library:NiceUrl($currentPage/parent::node/@id)}">
            <xsl:attribute name="class">selectDrop</xsl:attribute>
            <xsl:text><xsl:value-of select="$currentPage/parent::node/@nodeName"/></xsl:text>
            </a>
            <ul>
              <xsl:for-each select="$currentPage/ancestor-or-self::node /node[data[@alias='productType']]">
                <li>
                  <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:if test="$currentPage/ancestor-or-self::node/data[@alias='productType'] = ./@id">
                      <xsl:attribute name="class">selectArea</xsl:attribute>
                    </xsl:if>
                    <xsl:if test="$currentPage/@id = current()/@id">
                      <xsl:attribute name="class">select</xsl:attribute>
                    </xsl:if>
                    <xsl:value-of select="@nodeName"/>
                  </a>
                </li>
              </xsl:for-each>
            </ul>
          </li>
        </ul>

     

    I always find this page really helpful http://umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcuts 

    Rich

  • Eddie Foreman 215 posts 288 karma points
    Sep 27, 2010 @ 15:37
    Eddie Foreman
    0

    Hi Rich

    Will give it a try and thanks for the wiki reference.

    Thanks

    Eddie

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies