Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Feb 10, 2012 @ 14:04
    Fuji Kusaka
    0

    Converting Id to NiceUrl

    Hi All,

    I have an issue here where i need to convert an Id from my ContentPicker to a NiceUrl. 

    Cant save the file getting Error Value was either too large or too small for an Int32

          <xsl:variable name="chosenPage" select="$currentPage/data[@alias='urlBanner']"/>
    <xsl:template match="/">
      <!-- start writing XSLT -->
       <xsl:if test="number($BannerImage)">   
       
            <xsl:for-each select="umbraco.library:GetMedia($BannerImage, 'true')/Image">          
             <li
                 <href="{umbraco.library:NiceUrl($chosenPage)}">          
                   <xsl:element name="img">
                       <xsl:attribute name="src">
                           <xsl:value-of select="umbracoFile"/>
                     </xsl:attribute
                   </xsl:element>
              </a>
              </li>     
             </xsl:for-each>    
     
    </xsl:if>

     

    //fuji

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 10, 2012 @ 14:13
    Tom Fulton
    0

    Hi fuji,

    You need to wrap the NiceUrl around a test to ensure $chosenPage has a value, otherwise it may not when you save the file and umbraco does it's testing (just like you do with GetMedia.

    <xsl:iftest="$chosenPage &gt; 0">
    ....
    </xsl:if>

    Also not sure if you meant to or not but it looks like you're using the old schema on that variable ;)

    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Feb 10, 2012 @ 15:48
    Fuji Kusaka
    0

    Hi Tom,

    No wasnt meant to be using the old schema. I still didnt get it to work. I forgot to mention that i added a new Property in my Image Media Content with type  contentPicker to enable user to add a link to the image upload from the media section itself.

    I know it might sound weird but the client wanted to be able to get each image a specific url to the content of the website itself.

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 10, 2012 @ 15:53
    Tom Fulton
    1

    Hi Fuji,

    Are you getting the same error?  The above should really fix that error.

    But also, is your content picker value (urlBanner) coming from the media item itself?  If so you can eliminate the $chosenPage and just get it from your media varaible

    <xsl:template match="/">
        <!-- start writing XSLT -->
        <xsl:if test="number($BannerImage)">
            <xsl:for-each select="umbraco.library:GetMedia($BannerImage, 'true')/Image">
                <xsl:variable name="chosenPage" select="./urlBanner"/>
                <!-- Grab the content picker value from the Image -->
                <xsl:if test="$chosenPage &gt; 0">
                    <!-- Only show the below if a value was selected in the content picker.  You could move this around if you want other behavior, but it needs to wrap the NiceUrl in case the value is empty -->
                    <li>
                        <a href="{umbraco.library:NiceUrl($chosenPage)}">
                            <xsl:element name="img">
                                <xsl:attribute name="src">
                                    <xsl:value-of select="umbracoFile"/>
                                </xsl:attribute>
                            </xsl:element>
                        </a>
                    </li>
                </xsl:if>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>

    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Feb 10, 2012 @ 16:26
    Fuji Kusaka
    0

    Hi Tom,

    Thanks for the response. Well i didnt changed the variable, so wasnt getting any results.

     

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft