Copied to clipboard

Flag this post as spam?

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


  • GLindqvist 13 posts 13 karma points
    May 10, 2011 @ 13:35
    GLindqvist
    0

    Get related links to work with Umbraco 4.0.2.2

    We are using Nibble packages for Related Links datatype for Umbraco 4.0.2.2.

    <?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:relatedLinks.library="urn:relatedLinks.library"
        exclude-result-prefixes="msxml umbraco.library relatedLinks.library">
    
    
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:param name="currentPage"/>
    
    <xsl:template match="/">
    <ul>
    <xsl:for-each select="relatedLinks.library:getRelatedLinks($currentPage/data [@alias = 'link'])/links/link">
    <li>
    <xsl:value-of select="./@newwindow"/>
    <a href="{./@link}">
    <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"/>
    </a>
    </li>
    
    
    </xsl:for-each>
    </ul>
    
    </xsl:template>
    
    </xsl:stylesheet>

    But the select for the for-each won't work. I have added the related link datatype as property with a alias 'link' for the document type. Also added the macro for the xslt to the doucment type template.

    The code will only generate:

    <ul></ul>


    Any ideas? 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 10, 2011 @ 23:13
    Jan Skovgaard
    0

    Hi

    And there has been selected some links so it's not in fact empty? If so...have you tried to see if it's solved by refreshing the XML cache by going to the "Content" node, right click and select "Republish entire site" ?

    Otherwise what happens if you try to fetch the XML by writing it out in a <textarea> like this

    <textarea>
       <xsl:copy-of select="relatedLinks.library:getRelatedLinks($currentPage/data [@alias = 'link'])/links/link" />
    </textarea>

    Hope this helps.

    /Jan

  • GLindqvist 13 posts 13 karma points
    May 11, 2011 @ 11:33
    GLindqvist
    0

    I have made some test on my own to see if it finds links:

    <p><xsl:value-of select="relatedLinks.library:getRelatedLinks($currentPage/data [@alias = 'link'])/links/link" /></p>
    
    <xsl:variable name="linksPropertyAlias" select="/macro/links"/>
    <xsl:variable name="links" select="relatedLinks.library:getRelatedLinks($currentPage/data [@alias = 'link' and not(@isDoc) and name()=$linksPropertyAlias]/*)"/>
    
    Items in list: <xsl:value-of select="count($links/link)"/> <br />

    Both case it prints empty:

    <p></p>
    Items in list: 0


    I also tried with textarea and got this result:

    <ul />

    Plus the rest of the ending code from the page, footer etc.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 11, 2011 @ 18:12
    Jan Skovgaard
    0

    Have you tried to refresh the XML cache by republishing the entire site to make sure it's not because the content is missing from the umbraco.config file?

    You could also try to open this file, which is found in the App_Data folder to see if the links you have entered can be found in it. If not a republish should do the trick.

    Hope this helps.

    /Jan

  • GLindqvist 13 posts 13 karma points
    May 11, 2011 @ 22:32
    GLindqvist
    0

    Great tips, going to try it out tomorrow. Thanks! 

Please Sign in or register to post replies

Write your reply to:

Draft