Copied to clipboard

Flag this post as spam?

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


  • aaronb 97 posts 116 karma points
    Aug 20, 2010 @ 22:42
    aaronb
    0

    Trying to display related links from the root node, on all pages.

    I have a set of footer links which I want to be customizable by the user. There's six lists, with variable numbers of links in each list.

    The related links datatype behaves exactly as I'd want it to as far as entering the content, but I can't get my xslt to display this correctly on any page other than the current page.

    Here's the part of my code that's relevant - it's just the related links xslt macro code.

    I have tried all kinds of paths in the for-each loop such as $currentPage/ancestor-or-self, and root etc. but I haven't got it working. As of now, the following code works on the homepage, but not on any of the subpages.

    Alternatively, if I'm doing this really inefficiently any other ways would work too. Essentially I'm trying to achieve the same result as when you have a document field in a template, and set recursive to true.

    thanks for any suggestions.

    <xsl:variable name="propertyAlias" select="string('footerLinkOneList')"/>
      
      <xsl:template match="/">
    in macro
        <!-- The fun starts here -->
        <ul>
          <xsl:for-each select="$currentPage/* [name() = $propertyAlias and not(@isDoc)]/links/link">

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 20, 2010 @ 22:59
    Chriztian Steinmeier
    0

    Hi aaronb,

    If I understand you correct, this should do it:

    <xsl:for-each select="$currentPage/ancestor-or-self::*[footerLinkOneList][1]/footerLinkOneList/links/link">

    - It goes up through the ancestor axis and stops at the first one that has the 'footerLinkOneList' property, and then finds the link elements in there.

    /Chriztian

  • aaronb 97 posts 116 karma points
    Aug 21, 2010 @ 00:35
    aaronb
    0

    Perfect, thanks Chriztian!

Please Sign in or register to post replies

Write your reply to:

Draft