Copied to clipboard

Flag this post as spam?

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


  • Amigo 243 posts 568 karma points
    Sep 06, 2010 @ 13:19
    Amigo
    0

    Related Links with Media

    I use umbraco 4.5.2

    Im trying to use "Related Links with Media"

    But the only output i get from it is "<ul />" and nothiong else...

    My propperty alias is: "mylinks"

    Does anyone have an idea why??

    xslt:

    <?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" xmlns:tagsLib="urn:tagsLib"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib ">


      <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('mylinks')"/>
     
      <xsl:template match="/">

        <!-- The fun starts here -->
    <ul>

         <xsl:for-each select="$currentPage/data [@alias = $propertyAlias]/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>

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 06, 2010 @ 13:51
    Dirk De Grave
    0

    Seems you're using the old legacy xml schema for getting the links... and you're on a v4.5.2 installation. Please check the value of 

    <UseLegacyXmlSchema>false</UseLegacyXmlSchema>

    in umbracoSettings.config.

    If set to false, then this xslt should work, if set to true, you'll have to convert the xslt for use on the new xml schema. Check this wiki article (has some references to online xslt conversion tools)

     

    Hope this helps.

    Regards,

    /Dirk

     

     

  • Amigo 243 posts 568 karma points
    Sep 06, 2010 @ 14:47
    Amigo
    0

    Hi Dirk,

    It is already set to false....

    I have created a macro that uses 'RelatedLinkswithMedia.xslt' and inserted the macro on my page...
    Is that the right way to do i ?

    I also has run republish.aspx?xml=true...

    Nothing comes out....

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 06, 2010 @ 15:06
    Dirk De Grave
    0

    Hmm, let's try to output the complete xml for the page and see what's in there

    Just add some code to your xslt:

    <textarea><xsl:copy-of select="$currentPage" /></textarea>

    and paste it here so we can see what's in the xml?

     

    Cheers,

    /Dirk

  • Amigo 243 posts 568 karma points
    Sep 06, 2010 @ 15:20
    Amigo
    0

    Ok here it is, looks like my testlink is in the xml (marked with bold):

    <Subpage_rightcolumn id="1076" parentID="1072" level="2" writerID="0" creatorID="0" nodeType="1074" template="1075" sortOrder="1" createDate="2010-08-25T15:10:49" updateDate="2010-09-06T15:18:52" nodeName="Kunder" urlName="kunder" writerName="Administrator" creatorName="Administrator" path="-1,1072,1076" isDoc=""><subpageheadline>Here is a headline...</subpageheadline><video>http://www.youtube.com/v/8NZBxwjcwMc</video>;<mylinks><links><link title="eb dk" link="http://eb.dk" type="external" newwindow="1" /></links></mylinks><subpageteaser></subpageteaser><showVideo>0</showVideo><subpagecontent></subpagecontent><image>1055</image><imageLink>http://www.eb.dk</imageLink><imageTooltip>Læs mere her</imageTooltip><imageLinkTarget>_blank</imageLinkTarget><showImage>0</showImage><pageTitle>Kunder</pageTitle><description>her kommer meta beskrivelse til siden</description><keywords>keyword1, keyword2</keywords><umbracoNaviHide>0</umbracoNaviHide></Subpage_rightcolumn>

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 06, 2010 @ 15:39
    Dirk De Grave
    0

    Just realized I've made small mistake. If UseLegacyXmlSchema is set to false, then the new xml schema is used, otherwise the old xml schema is used. Yours is set to false, so you have to use the new xml syntax to get results... and the xslt you've pasted previously is still based on the old xslt schema.

    You'll have to update the xslt to:

    <xsl:for-each select="$currentPage/mylinks//links/link">

    That said, just another question for you: Did you upgrade from a pre 4.5 version? Or have started working with the v4.5.2 version from scratch. And if the latter, have you choosen to use the xslt template from the dropdown? If so, then this might be the issue. Let us know so we may report this as an issue on Codeplex.

    Hope this helps.

    Regards,

    /Dirk

  • Amigo 243 posts 568 karma points
    Sep 06, 2010 @ 15:55
    Amigo
    0

    Hi Dirk,

    Cool, now it works just great :-)

    Yes i work on a 4.0.xx that has been upgraded to the new 4.5.1 first and 4.5.2 later...

    Last thing, how can i make a check to see if there is no related files in my xslt?
    Because if i have no related files it still outputs only <ul />

    Thanks a lot for helping.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 06, 2010 @ 16:00
    Dirk De Grave
    1

    Perform an extra check on the number of 'link' items using;

    <xsl:if test="count($currentPage/mylinks//links/link) &gt; 0">
    ...
    </xsl:if>

    (must be set before the <ul> element)

    Cheers,

     

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft