Copied to clipboard

Flag this post as spam?

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


  • SiKo279 82 posts 238 karma points
    Aug 20, 2009 @ 13:10
    SiKo279
    0

    Related Links recursive ... how to get this to work?

    This XSLT thing is biting me everytime I even point at it. :(

    I want to define on the top node some Related Links, that need to appear on every page on the site.

    So, I found this post: our.umbraco.org/.../3331-Related-Links-Recursive

    But for some reason, it does not list the links, I added in the related links property on the top node (alias='servicesLinks')

    <xsl:template match="/">
      <h2>Services</h2>
        <!-- The fun starts here -->
         <ul>
          <xsl:for-each select="$currentPage/ancestor-or-self::node [count(data[@alias='servicesLinks']/links/link)&gt; 0] [1] /data[@alias='servicesLinks']/links/link">
            <li>
              <xsl:element name="a">
                <xsl:if test="./@newwindow = '1'">
                  <xsl:attribute name="target">_blank</xsl:attribute>
                </xsl:if>
                <xsl:choose>
                  <xsl:when test="./@type = 'external'">
                    <xsl:attribute name="href">
                      <xsl:value-of select="./@link"/>
                    </xsl:attribute>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:attribute name="href">
                      <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
                    </xsl:attribute>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="./@title"/>
              </xsl:element>
            </li>
          </xsl:for-each>
        </ul>
        <!-- Live Editing support for related links. -->
        <xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />

      </xsl:template>

    Any ideas?

  • Chris Koiak 700 posts 2626 karma points
    Aug 20, 2009 @ 14:15
    Chris Koiak
    100

    Try replacing "./@newwindow" with "@newwindow" and the same for all similar declarations.

    Why are you accessing the '0' index of the node list? should this not always only return one item. Try removing [0] and see what the output is.

    Failing both of these, can you post the output of

    <textarea cols="30" rows="30">
    <xsl:copy-of select="$currentPage/ancestor-or-self::node[count(data[@alias='servicesLinks']/links/link)&gt; 0] [1]/data[@alias='servicesLinks']/links/link" />
    </textarea>

     

  • Bert 128 posts 251 karma points
    Aug 20, 2009 @ 15:33
    Bert
    1

    delete

     <!-- Live Editing support for related links. -->
        <xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />
  • SiKo279 82 posts 238 karma points
    Aug 26, 2009 @ 11:16
    SiKo279
    0

    Thanks for the help guys.

    This is the code that worked for me.


      <xsl:template match="/">
      <h2>Services</h2>
        <!-- The fun starts here -->
         <ul>
          <xsl:for-each select="$currentPage/ancestor-or-self::node [count(data[@alias='servicesLinks']/links/link)&gt; 0] /data[@alias='servicesLinks']/links/link">
            <li>
              <xsl:element name="a">
                <xsl:if test="@newwindow = '1'">
                  <xsl:attribute name="target">_blank</xsl:attribute>
                </xsl:if>
                <xsl:choose>
                  <xsl:when test="@type = 'external'">
                    <xsl:attribute name="href">
                      <xsl:value-of select="@link"/>
                    </xsl:attribute>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:attribute name="href">
                      <xsl:value-of select="umbraco.library:NiceUrl(@link)"/>
                    </xsl:attribute>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="@title"/>
              </xsl:element>
            </li>
          </xsl:for-each>
        </ul>

      </xsl:template>

Please Sign in or register to post replies

Write your reply to:

Draft