Copied to clipboard

Flag this post as spam?

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


  • Thomas Egebrand Gram 63 posts 138 karma points
    May 21, 2011 @ 12:03
    Thomas Egebrand Gram
    0

    Dynamic image-gallery from data of child pages.

    Greetings everyone!

    I seem to have smashed my head quite a few times against the wall now, and i simply can't figure out what it is that i'm doing wrong. I'm new to Xslt - so bear with me! :)

    The idea:

    I'm trying to create a dynamic image gallery by having a "master-gallery" template. This template is supposed to have a macro, that takes all the childpages data, and turns them into a gallery for each childpage. Like this more or less:

    Master Gallery (where all the galleries are displayed with 1 image)
    -
    January
    - February
    - And so on..

    The child pages simply has a media picker, which picks the folder the user wants to load all the images from, and with the macro i then add a shadowbox to each link, whilst also using imagegen for thumbnails.

     

    The problem:

    While i'm able to get the galleries on the master-gallery page, the media picker ID doesn't change. It seems as if it doesn't change, or isn't working as a "for-each" and then only loads the id of the first childpage. Each of the childpages i've tested with of course has a different folder selected with the media picker, but it doesn't quite seem to work.

     

    The Xslt:

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <xsl:for-each select="umbraco.library:GetXmlNodeById('1134')/GalleriAlbum [@isDoc and umbracoNaviHide != '1']">
     
        <xsl:variable name="gallerimap" select="number($currentPage//gallerimap)" />
        <xsl:variable name="thumbWidth" select="number($currentPage//thumbbredde)" />
        <xsl:variable name="thumbHeight" select="number($currentPage//thumbhjde)" />    
      
            <xsl:if test="number($gallerimap)">
              <div class="gallery" id="forste">
                    <xsl:for-each select="umbraco.library:GetMedia($gallerimap, true())/Image">
                                       
                          <xsl:if test="umbracoFile !=''">
                            <a href="{umbracoFile}" title="{@nodeName}" rel="shadowbox[{@parentID}]">
                                    <img src="/imageGen.ashx?image={umbraco.library:UrlEncode(umbracoFile)}&amp;width={$thumbWidth}&amp;height={$thumbHeight}" width="{$thumbWidth}" height="{$thumbHeight}" alt="{@nodeName}" title="{@nodeName}" class="thumbnail" />
                                </a>
                        </xsl:if>
                    </xsl:for-each>
    </div>
            </xsl:if>
        </xsl:for-each>
        </xsl:template>


    Thanks for reading, i hope you can help. :)
    // Thomas

  • Thomas Egebrand Gram 63 posts 138 karma points
    May 21, 2011 @ 12:05
    Thomas Egebrand Gram
    0

    Can't edit my post for some reason; but i use Umbraco 4.7.0 by the way. :)
    // Thomas

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 21, 2011 @ 12:28
    Chriztian Steinmeier
    0

    Hi Thomas,

    If I understand you correct, you should just change the three variables to this:

    <xsl:variable name="gallerimap" select="gallerimap" />
    <xsl:variable name="thumbWidth" select="thumbbredde" />
    <xsl:variable name="thumbHeight" select="thumbhjde" />

    The way you define them right now, they'll always get the same value (taken from the first descendant of $currentPage, actually).

    Inside a for-each the context node will be set for you, so the gallerimap, thumbbredde and thumbhjde will be taken from the current node being processed.

    /Chriztian

     

  • Thomas Egebrand Gram 63 posts 138 karma points
    May 21, 2011 @ 13:19
    Thomas Egebrand Gram
    0

    Hi Chriztian,

    Thanks a lot! That worked spot on. :)
    Virtual high-five for you my friend, truly appreciated with the swift help!

    I'd high five you if i could!

    Have a nice day!

    // Thomas

Please Sign in or register to post replies

Write your reply to:

Draft