Copied to clipboard

Flag this post as spam?

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


  • suzyb 474 posts 932 karma points
    Jul 20, 2012 @ 19:41
    suzyb
    0

    Select images from damp recursivly

    I'm using damp to add slideshow images to my pages.  Each page can have it's own slideshow but if the current page doesn't have a slideshow I'd like to recurse up the tree and find the first parent / grand parent that does.

    To select a property recursivly I'd normally do something like this

    <xsl:variable name="data" select="$currentPage/ancestor-or-self::* [@isDoc and string(headerImage) != ''][1]/headerImage" />

    But I'm not sure how to do that with damp.  This is how I am selecting the slideshow images for the current page

    <xsl:variable name="data" select="$currentPage/bannerSlides/DAMP/mediaItem" />

    How do I modify this to select recursivly.

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Jul 20, 2012 @ 20:24
    Bjarne Fyrstenborg
    0

    Hi ..

    How is the content nodes structured?
    Do you have a slideshow node with children foreach slide item?

    I usually access each slide node either from a node with a master doc type, where MainMaster is my master doc type.

    <xsl:variable name="slide" select="$currentPage/ancestor-or-self::MainMaster/descendant-or-self::SlideItem [string(umbracoNaviHide) != '1']"/>

    or from root:

    <xsl:variable name="slide" select="$currentPage/ancestor-or-self::root/descendant-or-self::SlideItem [string(umbracoNaviHide) != '1']"/>

    Then you can loop through each slide item and get the properties on the slide item.

    In the loop you can easily get the images with DAMP stored as xml:

    <img src="{./slideImage/DAMP/mediaItem/Image/umbracoFile}" alt="" />

    /Bjarne

  • suzyb 474 posts 932 karma points
    Jul 20, 2012 @ 21:38
    suzyb
    0

    The slide is a property of my content page document type with alias "bannerSlides".  That property type is a data type I have set up that uses the damp with it set to save the full xml.

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Jul 20, 2012 @ 22:04
    Bjarne Fyrstenborg
    0

    Yes.. so you choose all slide images from the property with DAMP as datatype?

    but you can also loop through each selected image..

    <xsl:variable name="slide" select="$currentPage/ancestor-or-self::root/descendant-or-self::SlideItem [string(umbracoNaviHide) != '1']"/>
    <xsl:for-each select="$slide/bannerSlides/DAMP/mediaItem/Image">
    <img src="{./umbracoFile}" alt="" />
    </xsl:for-each>

    But if you have a node for each slide you are able to set other properties like a link, umbracoNaviHide property to hide the slide item and what else you might need.. or you could create a media item with more properties than the default properties.. but I prefer using content nodes/document types for this.

    /Bjarne

  • suzyb 474 posts 932 karma points
    Jul 21, 2012 @ 13:10
    suzyb
    0

    Sorry I don't understand what you mean.  As I understand itthis

    $currentPage/ancestor-or-self::root/descendant-or-self::SlideItem

    will select SlideItem nodes.  My slides are not their own document type though.

  • suzyb 474 posts 932 karma points
    Jul 21, 2012 @ 13:30
    suzyb
    0

    Actually I think I just worked it out. The following seems to work

        <xsl:variable name="data" select="$currentPage/ancestor-or-self::* [bannerSlides != ''][1]/bannerSlides/DAMP/mediaItem" />
  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Jul 21, 2012 @ 22:22
    Bjarne Fyrstenborg
    0

    Yes, it will select nodes which use SlideItem as document types.. there are multiple ways to create slideshows.. if you need more properties than just an image, it's probably better to use content nodes.. but if you only need to show images, you can select multiple images with DAMP or select a folder from media section either with the media picker or DAMP and loop through the folder images.

    I'm not sure you always get the images depending on where the currentpage with the slideshow is in the structure.. therefore I usually starts from root nodes and look through the structure..

    I think this will work too..

    <xsl:variablename="data"select="$currentPage/ancestor-or-self::root/descendant-or-self::*[@isDoc][bannerSlides != ''][1]/bannerSlides/DAMP/mediaItem"/>

    I often think this Xpath visualizer is a great help to get the data you want: http://pimpmyxslt.com/axesviz.aspx

    /Bjarne

Please Sign in or register to post replies

Write your reply to:

Draft