Copied to clipboard

Flag this post as spam?

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


  • jwijnker 7 posts 27 karma points
    Mar 25, 2011 @ 11:12
    jwijnker
    0

    Display Related Links

    Guys,

    I've made a documentType with a RelatedLinks property (called 'productLinks').

    To display the relatedLinks i've created a macro ('QuickLinks') with a parameter 'links' of type 'propertyTypePicker' to pick the correct property containing the relatedLinks. (Also checked the 'Show'-checkbox, although i don't know what's it's function...)

    In the template where i want the show the relatedLinks, i call the macro and pick the correct property.
    <umbraco:Macro links="[#productLinks]" Alias="QuickLinks" runat="server"></umbraco:Macro>

    I expect the list of links in the corresponding XSLT-script. But in there, i don't receive any links. When i try to pass the parameter-name:
    <umbraco:Macro links="productLinks" Alias="QuickLinks" runat="server"></umbraco:Macro>
    it is available in the XSLT.

    Is anyone familiar with this problem? Or does someone know how to pass the related links into the macro correctly?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 25, 2011 @ 11:26
    Jan Skovgaard
    0

    Hi jwijnker

    What version of Umbraco are you using? And what does your xslt code look like?

    /jan

  • jwijnker 7 posts 27 karma points
    Mar 25, 2011 @ 11:56
    jwijnker
    0

    Hi jan,

    my umbraco version is:"umbraco v 4.6.1 (Assembly version: 1.0.4029.25836)"

    My XSLT file (i'm still busy with...) looks like this:

    <xsl:output method="xml" omit-xml-declaration="yes"/>
     <xsl:param name="currentPage"/>
     <xsl:template match="/">

     <!-- Variables Used -->
     <xsl:variable name="links" select="/macro/links"/>

      <!-- Amount of items in the list -->
      Items in list: <xsl:value-of select="count(/macro/links)"/> <br />
                   <!-- NO RESULT (0)-->

     

      <!-- Links Data-->
      <xsl:value-of select="$links"/>
                   <!-- NO RESULT--> <xsl:for-each select="$links/ancestor-or-self::node">
     Link: <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/
    />
     </xsl:for-each>><br

    </xsl:template>

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 25, 2011 @ 12:49
    Tom Fulton
    0

    Hi,

    I noticed a couple problems in your code, but the below snippet should work.  Note you need to pass in only the property name and not with the [#] syntax.  I don't think this works well passing XML data.

    <umbraco:Macro links="productLinks" Alias="QuickLinks" runat="server"></umbraco:Macro>
    <!-- start writing XSLT -->
    <xsl:variable name="linksPropertyAlias" select="/macro/links"/>
    <xsl:variable name="links" select="$currentPage/* [not(@isDoc) and name()=$linksPropertyAlias]/*"/>
     
    Items in list: <xsl:value-of select="count($links/link)"/> <br />
     
    <!-- Links Data-->
    <xsl:for-each select="$links/link">
     Link: <xsl:value-of select="umbraco.library:NiceUrl(./@link)" />
    </xsl:for-each>
    <br/>

    -Tom

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 25, 2011 @ 12:59
    Tom Fulton
    0

    Also, I assumed you are using 4.5+ with the new XML schema.  You did have a reference to the old schema in your original XSLT...so if you are using that, just change the links variable line to:

    <xsl:variable name="links" select="$currentPage/data [@alias=$linksPropertyAlias]/*"/>
  • jwijnker 7 posts 27 karma points
    Mar 25, 2011 @ 13:24
    jwijnker
    0

    Tom,

    thanks for you're reply's. I was still working on it and so didn't read it in time.

    But, I found my solution by searching the forum and the web:
    So maybe it can help someone else...

      <!-- Variables Used -->
     <xsl:variable name="debug" select="0"/>
     <xsl:variable name="links" select="/macro/links"/>
     <xsl:variable name="title" select="/macro/title"/>


     <!-- Debugging -->
     <xsl:if test="$debug = 1">
      <textarea cols="100" rows="20" style="border:2px solid red; background-color: #eeee77; padding-left: 10px;">

      <!-- In debug, comment '/textarea' below, and enable at the end of the script. -->
      </textarea>

     </xsl:if>


    <ul>
     <h3 class="uppercase"><xsl:value-of select="$title"/></h3>
          <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc][@level=1]/* [name() = $links 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>

     <!-- Debugging -->
     <!--
      MAKE 'textarea' BELOW AVAILABLE IN DEBUG MODE
      </textarea>
     -->

  • 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.

    Continue discussion

Please Sign in or register to post replies