Copied to clipboard

Flag this post as spam?

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


  • Roger 195 posts 474 karma points
    Feb 27, 2013 @ 10:36
    Roger
    0

    XSLT Help Please!

    I have a page called hall of fame with a node id of 1185. This page is under the Homepage node like all the others.

    This page allows images to be added as sub pages like this


    >Homepage

    >>> Hall of Fame
    >>>>> Image 1
    >>>>> Image 2

    etc etc

    I need to show the umbracoFile thumbnail for all the images under this node but I need to be able to add the macro anywhere on the site. Its basically built like a gallery but without the individual gallery folders.

    Ive tried the following code but it only targets nodes directly under the root node:
        <xsl:variable name="hallNode" select="$currentPage/ancestor::root/Homepage/HallOfFame"/>
    <ul>
    <xsl:for-each select="$hallNode/HallImages">
        <xsl:sort select="jumpDate" order="descending"/>


        <li>
            <img title="{@nodeName}" src="{concat(substring-before(./*/umbracoFile,'.'), '_thumb.jpg')}" style="border: none;"/>
           
        </li>

    </xsl:for-each>
    </ul>
    Please can anyone help, site is going live today. I had no reply on my previous post
    Thanks
  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 11:05
    Rich Green
    1

    Hey Roger,

    Off the top of my head, your variable hallNode returns a node ID, not a node, so you need something like:

    <xsl:for-each select="umbraco.library:GetXmlNodeById($hallNode)/HallImages">

    Rich

     

     

     

  • Drew Garratt 44 posts 192 karma points
    Feb 27, 2013 @ 11:50
    Drew Garratt
    1

    Hey Roger,

    I always found that if I was setting a Macro that relied on a paticular node it was quicker to access it directly by it's ID may well be the easiest way.

    Adapted from your example something like the following

    <!-- Node Locations -->

    <xsl:variable name="hallNode" select="1050"/>

    <!-- END Node Locations -->

    <xsl:template match="/">

    <ul>

      <xsl:for-each select="umbraco.library:GetXmlNodeById(@id)//HallImages [@isDoc]">

     <xsl:sort select="jumpDate" order="descending"/>

       <li>

           <img title="{@nodeName}" src="{concat(substring-before(./*/umbracoFile,'.'), '_thumb.jpg')}" style="border: none;"/>       

       </li>   

      </xsl:for-each>

    </ul>

    </xsl:template>

  • Roger 195 posts 474 karma points
    Feb 27, 2013 @ 12:04
    Roger
    0

    Hi Drew, that didn't work sorry. I changed the hallNode variable value to 1185, the id of the parent

  • Roger 195 posts 474 karma points
    Feb 27, 2013 @ 12:06
    Roger
    0

    Hi Rich,

    Your code worked except for some reason the src of the image is only bringing back "_thumb.jpg" and not the actual value of the umbracoFile?

    Thanks for the help

    Roger

  • Roger 195 posts 474 karma points
    Feb 27, 2013 @ 12:15
    Roger
    0

    Ok, i've sorted it, thanks guys.

    I needed to change the img src to <img src="/ImageGen.ashx?image={concat(substring-before(umbracoFile,'.'), '_thumb.jpg')}&amp;width=140&amp;height=94"/>

    Thanks for all the help!

    Roger

  • Drew Garratt 44 posts 192 karma points
    Feb 27, 2013 @ 12:16
    Drew Garratt
    1

    Glad we could help Roger

Please Sign in or register to post replies

Write your reply to:

Draft