Copied to clipboard

Flag this post as spam?

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


  • Bert 128 posts 251 karma points
    Aug 03, 2009 @ 17:30
    Bert
    0

    Related Links Recursive

    In my site I need to load the related links property recursive. This hasn't been a problem with simple datatypes, but the related links just doesn't want to work recursive.

    I wonder if anyone has any experience with getting this to work? On the old forums the only suggestion was to use the property of the lvl 1 document by default but that just doesn't work for my setup. i need the real recursion :) Any ideas?

  • Bert 128 posts 251 karma points
    Aug 04, 2009 @ 11:46
    Bert
    4

    The solution:

        <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::node [count(data[@alias='relatedLinks']/links/link)&gt; 0] [1] /data[@alias='relatedLinks']/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>
  • RolandWolters 42 posts 63 karma points
    Jul 28, 2010 @ 12:53
    RolandWolters
    0

    I am trying to port this to the 4.5.x xml schema, but I can't get it to work. 

    Here is the changed foreach part:

     

     <xsl:for-each select="$currentPage/ancestor-or-self::* [name() = $propertyAlias and not(@isDoc)]/links/link"
         

    What am i doing wrong?

  • Gerty Engrie 130 posts 489 karma points c-trib
    Sep 15, 2010 @ 23:14
    Gerty Engrie
    0

    Works for me (rl is my propertyname...testsite ;)  ) :

     

    <xsl:for-each select="$currentPage/ancestor-or-self::CWS_Home/descendant::*[ count(rl/links/link) > 0]/rl/links/link">
    <xsl:value-of select="@title"/><br/>
    </xsl:for-each>



  • Damiaan 442 posts 1301 karma points MVP 6x c-trib
    Dec 13, 2010 @ 12:42
    Damiaan
    0

    Thanks, it's working in 4.5.2 for me.

  • Dwayne A 97 posts 117 karma points
    Feb 10, 2011 @ 16:02
    Dwayne A
    0

    I have the same problem in 4.6.1. I am creating several lists of links in my master template that need to be inherited sitewide. They show up on the first child template and stop there. I've tried above and no go. Any suggestions?

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [  <!ENTITY nbsp "&#x00A0;">]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


      <xsl:output method="xml" omit-xml-declaration="yes" />

      <xsl:param name="currentPage"/>
      
      <!-- Input the related links property alias here -->
      <xsl:variable name="propertyAlias" select="string('maalgrupper')"/>
      
      <xsl:template match="/">

        <!-- The fun starts here -->
        <ul>
          <xsl:for-each select="$currentPage/* [name() = $propertyAlias and not(@isDoc)]/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>

    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft