Copied to clipboard

Flag this post as spam?

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


  • hetaurhet 245 posts 267 karma points
    May 27, 2011 @ 12:23
    hetaurhet
    0

    creating xslt for related links data type

    I am using umbraco 4.7.0. I want to use related links data type(which is by default available in this version), so added in doucment type as one of the properties.

    while creating xslt file, after giving file name it should automatically add xml code for related links. But it is not doing so. Can anybody help me to solve this. What is missing? is any file mission? or any settings need to be done?

  • Kim Andersen 1447 posts 2196 karma points MVP
    May 27, 2011 @ 22:47
    Kim Andersen
    1

    Hi

    When you create the XSLT-file for this task, I'm pretty sure that you can select a build-in xslt template from the dropdown called something like "Related links". Is this the XSLT you are working with? If not could you maybe try out that code to see if it fits your needs :)

    /Kim A

  • hetaurhet 245 posts 267 karma points
    May 28, 2011 @ 09:15
    hetaurhet
    0

    yes, i am using build-in xslt template. but the code which should come automatically is not getting generated.

  • Kim Andersen 1447 posts 2196 karma points MVP
    May 28, 2011 @ 16:04
    Kim Andersen
    0

    Hmm...that sounds weird. I'll see if I can find the code for you then. But it sure does sound weird that the code is not being generated. Is it only the "Related links" predefined template that does not work, or is there a problem on the other ones as well?

    /Kim A

  • Lesley 284 posts 143 karma points
    May 29, 2011 @ 00:39
    Lesley
    0

    I think this is what you're after? (I've copied it from \umbraco\xslt\templates\, where you should have a dozen or so xslt files.)

    <?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" {0}
        exclude-result-prefixes="msxml umbraco.library {1}">
    
    
      <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('links')"/>
    
      <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>

     

  • hetaurhet 245 posts 267 karma points
    May 29, 2011 @ 05:17
    hetaurhet
    0

    Problem is only with 'Related Links'  xslt.

    Thank you for the code. But actually i want to figure out that why code is automatically not appearing. Is something got deleted or missing?

  • Lesley 284 posts 143 karma points
    May 29, 2011 @ 13:24
    Lesley
    0

    Do you have a file \umbraco\xslt\templates\RelatedLinks.xslt? It would be strange if it were there but not working the same way as the other templates...

  • hetaurhet 245 posts 267 karma points
    May 31, 2011 @ 06:44
    hetaurhet
    0

    yes, i have this file. And now I got one clue that it was not generating code for the file name in which '&' character appears. My file name was Q&ARelatedLinks. can anybody tell me that is that this '&' makes different in other things also? As in my template, Tab functionality also doesnot work which is having '&' character in tabs caption. Also, if I want to use this character as it is what can I do?

  • Lesley 284 posts 143 karma points
    May 31, 2011 @ 11:34
    Lesley
    0

    Do you have any better luck if you encode the ampersand like you would in html, like &amp;

    So you have Q&amp;ARelatedLinks

     

  • hetaurhet 245 posts 267 karma points
    May 31, 2011 @ 17:11
    hetaurhet
    0

    i will check out

  • hetaurhet 245 posts 267 karma points
    Jun 04, 2011 @ 10:42
    hetaurhet
    0

    using name like this Q&amp;ARelatedLinks .... also gives blank xslt.... so i think better not to use this character in name.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Jun 05, 2011 @ 22:31
    Chriztian Steinmeier
    0

    Hi hetauhet,

    Sounds very likely to be a filename problem - when you name an XSLT file in Umbraco, a physical file is generated which will be susceptible to the limitations of the underlying filesystem. Of course, we can agree that Umbraco should handle this gracefully and either flag the name as invalid, or apply a clever "fix" (like using "and" in case of an ampersand, etc.) to the filename and maybe keep the macro name intact?

    In any case, you could file a bug report on umbraco.codeplex.com 

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft