Copied to clipboard

Flag this post as spam?

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


  • monkey123 6 posts 26 karma points
    Dec 12, 2011 @ 16:41
    monkey123
    0

    Images from Umbraco folder straight to Carousel

    Hi,

    I'm a complete beginner on Xslt and i'm hitting a brick wall, I wondered if somebody could point me in the right direction in getting all images contained in an Umbraco folder (ID 1079) and displaying them in a carousel that I have already put to use on the site.  At the moment I have the carousel as a div and have listed all the images seperately within that to get the carousel to work.  But i'd now like the option of it automatically pulling the images from the folder and using them.

    Thanks for any help!

  • Kim Andersen 1447 posts 2197 karma points MVP
    Dec 12, 2011 @ 16:47
    Kim Andersen
    0

    Hi Monkey

    I'm not sure I can remember the XML schema for the media-section, but I think something like this will work for you:

    <xsl:variable name="mediaFolder" select="umbraco.library:GetMedia('1079',1)" />
    <xsl:for-each select="$mediaFolder/Image">
    <img src="{umbracoFile}" alt="{@nodeName}" />
    </xsl:for-each>

    If im correct, the for-each loop will run through the images in the sepcified folder, and list all of the images in that folder.

    But as said, I'm not 100% sure that the code will work out of the box, maybe you have to do some small changes to it.

    /Kim A

  • monkey123 6 posts 26 karma points
    Dec 12, 2011 @ 16:56
    monkey123
    0

    Hi Kim,

    You're spot on, that works great.  I can't thank you enough!

    It's displaying each photo now in the carousel as I add them, I just wondered though (and I'm taking advantage of your knowledge now) ... how would I set these so that when the user clicks on the photo it takes them to a page or link... as before adding the xslt I was using <a href> ...

    Thanks again!

  • Kim Andersen 1447 posts 2197 karma points MVP
    Dec 12, 2011 @ 17:02
    Kim Andersen
    0

    Cool, grea to hear.

    You can just put a link inside the for-each loop like this:

    <xsl:for-eachselect="$mediaFolder/Image">
       <a href="http://google.com">
    <imgsrc="{umbracoFile}"alt="{@nodeName}"/>
    </a>
    </xsl:for-each>

    This will, however, give you the same link on all of the images. Don't know if you want this.

    Or do you need to have a unique link on each image?

    /Kim A

  • monkey123 6 posts 26 karma points
    Dec 12, 2011 @ 17:05
    monkey123
    0

    Yeah unfortunately it will be a unique link on each image, and ideally this would be something the user could set...?

    Thanks!

  • monkey123 6 posts 26 karma points
    Dec 12, 2011 @ 18:48
    monkey123
    0

    Hi again,

    I managed to solve this by creating a different type of image in Umbraco and linking to that.  Thanks so much for your help!

  • Kim Andersen 1447 posts 2197 karma points MVP
    Dec 12, 2011 @ 18:59
    Kim Andersen
    0

    Hi again

    Well, great that you've already found your solution. Just want to come up with my inputs anyway :)

    You could either expand the image-media type with a field for the link, and then just use that link on the image.

    A whole other way could be to create the banner in the content section, using some media pickers and some content pickers to define which images and links should be shown in the banner.

    But if you found your solution everything is good right :)

    /Kim A

  • Aditya.A 77 posts 96 karma points
    Jul 25, 2013 @ 12:09
    Aditya.A
    0

    can u give me the whole code i need to incorporate the same..very urgent

Please Sign in or register to post replies

Write your reply to:

Draft