Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Nov 17, 2010 @ 07:23
    syn-rg
    0

    Content picker NiceUrl

    I've created an image gallery slideshow. Each image is wrapped in a <a href> tag to link to the corresponding project. The user uploads the image then using the custom content picker "projectLink" pick which page they need to link to. This is working, however the URL displaying the node number, not the full URL name.

    I've tried adding the NiceUrl code to the link but this causes errors and doesn't work. I'm using 4.5.
    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"
    exclude-result-prefixes="msxml umbraco.library">

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

    <xsl:param name="currentPage"/>
    <xsl:variable name="imagesPerRow" select="6"/>

    <!-- =============================================================== -->

    <xsl:template match="/">
    <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('slider1', '/css/anythingFader.css')"/>

    <!-- a little hack to work around the xslt syntax checker when opening/closing UL lists in two separate IF statements -->
    <!-- if it weren't for IE we could use a single UL and simply float the LI's and they'd auto-wrap -->
    <!-- but for IE we either need separate UL rows or else we need to hard-code the LI's height in CSS -->
    <!-- this approach with separate UL rows works in all browsers and row heights -->
    <xsl:variable name="ulOpen"><xsl:text>&lt;ul id="slider1"&gt;</xsl:text></xsl:variable>
    <xsl:variable name="ulClose"><xsl:text>&lt;/ul&gt;</xsl:text></xsl:variable>

    <xsl:for-each select="$currentPage/* [@isDoc][string(umbracoNaviHide) != '1']">
    <!-- open a row of images -->
    <xsl:if test="position() = 1 or position() mod $imagesPerRow = 0">
    <xsl:value-of select="$ulOpen" disable-output-escaping="yes" />
    </xsl:if>

    <!-- display each image in the row, with the count of photos in each gallery -->
      <li>
        <a href="{projectLink}" title="{projectLink}">
          <xsl:if test="homeImage != ''">
            <img alt="">
            <xsl:attribute name="src">
              <xsl:value-of select="homeImage" />
            </xsl:attribute>  
          </img>
          </xsl:if>
        </a>
      </li>

      
    <!-- close the row of images -->
    <xsl:if test="position() = ($imagesPerRow - 1) or position() mod ($imagesPerRow - 1) = 0 or position() = last()">
    <xsl:value-of select="$ulClose" disable-output-escaping="yes"/>
    </xsl:if>
    </xsl:for-each>

    </xsl:template>

    <!-- =============================================================== -->

    </xsl:stylesheet>
  • Rich Green 2246 posts 4008 karma points
    Nov 17, 2010 @ 07:44
    Rich Green
    0

    Hey JV,

    Try this

    <!-- display each image in the row, with the count of photos in each gallery -->
      <li>
        <a href="{umbraco.library:NiceUrl(projectLink)}" title="{umbraco.library:GetXmlNodeById(projectLink)/@nodeName}">
          <xsl:if test="homeImage != ''">
            <img alt="">
            <xsl:attribute name="src">
              <xsl:value-of select="homeImage" />
            </xsl:attribute>  
          </img>
          </xsl:if>
        </a>
      </li>

    Rich

  • syn-rg 282 posts 425 karma points
    Nov 17, 2010 @ 23:20
    syn-rg
    0

    Hi Rich,

    I've tried that, keeps throwing the following error:

    Error occured
    System.OverflowException: Value was either too large or too small for an Int32.

     

    JV

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 18, 2010 @ 03:17
    Tom Fulton
    0

    Hi JV

    You need to wrap the NiceUrl in an if statement to ensure projectLink has a value (it won't during the save-test)

    <xsl:if test="string(projectLink) != ''">  
    <li>

       
    <a href="{umbraco.library:NiceUrl(projectLink)}" title="{umbraco.library:GetXmlNodeById(projectLink)/@nodeName}">
         
    <xsl:if test="homeImage != ''">
           
    <img alt="">
           
    <xsl:attribute name="src">
             
    <xsl:value-of select="homeImage" />
           
    </xsl:attribute>  
         
    </img>
         
    </xsl:if>
       
    </a>
     
    </li>
    </xsl:if>
  • syn-rg 282 posts 425 karma points
    Nov 18, 2010 @ 05:18
    syn-rg
    0

    Thanks Tom! You've saved me again.

    Here's my final code:

    <?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"
    exclude-result-prefixes="msxml umbraco.library">

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

    <xsl:param name="currentPage"/>
    <xsl:variable name="imagesPerRow" select="6"/>

    <!-- =============================================================== -->

    <xsl:template match="/">
    <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('slider1', '/css/anythingFader.css')"/>

    <!-- a little hack to work around the xslt syntax checker when opening/closing UL lists in two separate IF statements -->
    <!-- if it weren't for IE we could use a single UL and simply float the LI's and they'd auto-wrap -->
    <!-- but for IE we either need separate UL rows or else we need to hard-code the LI's height in CSS -->
    <!-- this approach with separate UL rows works in all browsers and row heights -->
    <xsl:variable name="ulOpen"><xsl:text>&lt;ul id="slider1"&gt;</xsl:text></xsl:variable>
    <xsl:variable name="ulClose"><xsl:text>&lt;/ul&gt;</xsl:text></xsl:variable>

    <xsl:for-each select="$currentPage/* [@isDoc][string(umbracoNaviHide) != '1']">
    <!-- open a row of images -->
    <xsl:if test="position() = 1 or position() mod $imagesPerRow = 0">
    <xsl:value-of select="$ulOpen" disable-output-escaping="yes" />
    </xsl:if>

    <!-- display each image in the row, with the count of photos in each gallery -->
    <xsl:if test="string(projectLink) != ''">  
    <li>
        <a href="{umbraco.library:NiceUrl(projectLink)}" title="{umbraco.library:GetXmlNodeById(projectLink)/@nodeName}">
          <xsl:if test="homeImage != ''">
            <img alt="">
            <xsl:attribute name="src">
              <xsl:value-of select="homeImage" />
            </xsl:attribute>  
          </img>
          </xsl:if>
        </a>
      </li>
    </xsl:if>

      
    <!-- close the row of images -->
    <xsl:if test="position() = ($imagesPerRow - 1) or position() mod ($imagesPerRow - 1) = 0 or position() = last()">
    <xsl:value-of select="$ulClose" disable-output-escaping="yes"/>
    </xsl:if>
    </xsl:for-each>

    </xsl:template>

    <!-- =============================================================== -->

    </xsl:stylesheet>
Please Sign in or register to post replies

Write your reply to:

Draft