Copied to clipboard

Flag this post as spam?

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


  • olst 69 posts 88 karma points
    Nov 01, 2011 @ 12:52
    olst
    0

    Confused - best way to create image slider

    Hi.

    Just to note, by working so far with Umbraco, I can see it's a wonderful cms, and it seems that a lot of effort and thought have been put in it, obviuosly.

     

    I'm trying to create an image slider, which contains a set of images to display and swap, a set of smaller preview images and some teaser texts for each image.

    What is thre best way to do this in umbraco ?

    I have all the slider scripts and css, but how do I put it on the page ?

    I've seen an example in the Umedia skin, and it looks pretty robust, what I don't understand is where the slider macro used, and how it all fits in basically...

    Thanks.

  • Rich Green 2246 posts 4008 karma points
    Nov 01, 2011 @ 13:00
    Rich Green
    1

    Hi Olst,

    The key point to remember with umbraco is that no mark up gets changed at all, so the basic concept is:

    1) Get your Gallery / slider working in HTML within your Umbraco site (just hard coded and using static images etc.)

    2) Write some XSLT / Razor macros to pull data from Umbaco which mimics your mark up exactly so effectivley swapping out the static html for dynamic Umbraco values.

    There is no 'Wizard' to do this as every image gallery is different as if every Umbraco solution.

    Make sense?

    Rich 

  • olst 69 posts 88 karma points
    Nov 01, 2011 @ 14:13
    olst
    0

    Hi rich, and thanks for the reply,

    let's break this down to pieces.

    I've been reading some material about using razor in umbraco...

    so, I created a document type called ImageSliderItem, which has the properties image and teaser text.

    then I created another document type called ImageSlider which has a child document type - ImageSliderItem.

    How would I reference the ImageSliderItem properties in an Xslt file ?

     

    I've seen this example:

     <xsl:variable name="sliderNode" select="$currentPage/parent::*/child::*[@level=1]"/>

    but how do I format the select in my case ?

  • Mr A 216 posts 278 karma points
    Nov 01, 2011 @ 14:34
    Mr A
    0

    Which plugin you using for image slider ?

  • olst 69 posts 88 karma points
    Nov 01, 2011 @ 15:00
    olst
    0

    I'm using estro slider.

    my Xslt is as follows:

     

    <!-- start writing XSLT -->
      <xsl:variable name="sliderNode" select="$currentPage/parent::*/child::*[@level=1]"/>

    <div id="home-carousel">
      <div class="peKenBurns" data-mode="swipe" data-logo="disabled" data-shadow="disabled"
             data-thumb="fixed" data-controls="inner" data-autopause="image" data-captions="disabled">
        <xsl:for-each select="$sliderNode/child::MediaSlider">
          <div id="CarouselItem" runat="server" class="peKb_active" data-delay="5" data-align="center"
                 data-thumb="{imageSmall}" data-transition="flyBy">
            <img src="{image}" />
            <h1><xsl:value-of select="teaserText" /></h1>
          </div>
        </xsl:for-each>
       </div>
    </div>

    </xsl:template>

     

    I've created a top level content node called Homepage Image Slider,

    where my editors can upload the actual images and content.

    Now, how do I use this specific image slider (with its respective images) in the content template ?

  • Mr A 216 posts 278 karma points
    Nov 01, 2011 @ 15:37
    Mr A
    0

    Well I am not familiar with xslt , but using Razor you can just iterate the children of the medianode which in this case is Homepage Image Slider  or you can simply create a folder in your content page and then add cropped images to that folder and then call that folder within the slider. For instance 

    Slideshow

    image1

    image2

    image3

    Razor Syntax:

    @using umbraco.MacroEngines
    @{
        
        DynamicNode node new DynamicNode(1132); //nodeid of slideshow folder

        string files "";
        int 0;
        string javascript "";      

    }

    <div id="home-carousel">

    @foreach (var page in node.ChildrenAsList)
                    {

                       <img id="[email protected]()" src="/[email protected]("slideImage").Value&width=678&height=276" alt="@page.GetProperty("caption").Value" />
                        i++;
                    }

    </div>

    slideimage is the property of document type slideshow. Hope it make sense to you .

  • olst 69 posts 88 karma points
    Nov 01, 2011 @ 16:29
    olst
    0

    Hi Mr A,

    I've used your code and modified it a bit for my needs, but I get an error message in the page, saying object reference not set to an instance of an object.

    I've checked it and the loop runs only 1 time, maybe I need to reference the children's children? What am I doing wrong ?

     let me just say that the slideshow content item i've created for uploading the images is not yet published (if that matters).

    @using umbraco.MacroEngines
    @{
        
        DynamicNode node new DynamicNode(1068)//nodeid of slideshow content item

        int 0;     
    }

    <div id="home-carousel">
    @foreach (var page in node.ChildrenAsList)
    {
        <div id="[email protected]()" runat="server" class="peKb_active" data-delay="5" data-align="center"
               data-thumb='page.GetProperty("smallImage").Value'
               data-transition="flyBy">
             <img id="[email protected]()" src='page.GetProperty("image").Value' alt='@page.GetProperty("caption").Value' />
             <h1>@page.GetProperty("teaserText").Value</h1>
        </div>
                       
        i++;
    }
    </div>

  • Mr A 216 posts 278 karma points
    Nov 01, 2011 @ 16:33
    Mr A
    0

    can you post your navigation tree , also have you got properties image and caption in your document type. What version are you using ?

  • olst 69 posts 88 karma points
    Nov 01, 2011 @ 16:44
    olst
    0

    I'm using version 4.7, my content tree is :

    Content

    -> Simple Site (document type is Homepage) ----> some more pages beneath.

    -> Homepage Image Slider (of type ImageSlider) ---> Item1, Item2, Item3, Item4 (all of type ImageSliderItem)

     

    ImageSliderItem has the following properties:

    Image of type upload, ImageSmall of type upload, TeaserText of type Textbox Multiple

    p.s. I changed the "caption" reference in the razor code to "teaserText", but it still didn't help.

    Thanks, we're close to solving it ....

  • Mr A 216 posts 278 karma points
    Nov 01, 2011 @ 17:05
    Mr A
    0

    Can you send the link for estro slider plugin so that i can reproduce and test on my test website .

  • Mr A 216 posts 278 karma points
    Nov 01, 2011 @ 17:06
    Mr A
    0

    The above code works fine for the slider on my test website which is (www.steelescarpets.co.uk)

  • Mr A 216 posts 278 karma points
    Nov 01, 2011 @ 17:14
    Mr A
    0

    I guess this is a paid slider , cant find a free demo version of it .Have you bought this slider looks oryt

  • olst 69 posts 88 karma points
    Nov 01, 2011 @ 17:42
    olst
    0

    As it turns out, I had to publish the ImageSlider content item before I could reference it in razor,

    otherwise it just would not get a reference to that node.

    So the final code is;

    @foreach (var page in node.ChildrenAsList)
    {
        <div id="[email protected]()" runat="server" class="peKb_active" data-delay="5" data-align="center"
               data-thumb='@page.GetProperty("imageSmall").Value'
               data-transition="flyBy">
             <img id="[email protected]()" src='@page.GetProperty("image").Value' alt='@page.GetProperty("teaserText").Value' />
             <h1>@page.GetProperty("TeaserText").Value</h1>
        </div>
                       
        i++;
    }

     

    Thanks again for your help.

  • olst 69 posts 88 karma points
    Nov 01, 2011 @ 17:44
    olst
    0

    p.s. it's a great slider plugin, I bought it and am using it in my site...

  • Mr A 216 posts 278 karma points
    Nov 01, 2011 @ 17:51
    Mr A
    0

    Glad to hear it worked out , can you accept the answer so that other users can find it easy in future

  • Salman Ansari 7 posts 27 karma points
    Nov 06, 2012 @ 10:59
    Salman Ansari
    0

    Hi,

    I have done this as follows and working for me.

    Tree Structure

    Content

      Image

    ImageGallery(from ImageGallery_Master Doc Type )

    Image1.(from ImageGallery_Item Doc Type )

    Image2(from ImageGallery_Item Doc Type )

    Image3(from ImageGallery_Item Doc Type )

    Macro Script As follows Search Gallery Item first then take Photo and PhotoText of particular Node 

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{    

        var root = Model.AncestorOrSelf();

       var nodes = root.Descendants("ImageGallery_Item");

         

        foreach (var node in nodes)

        {

         

         <div class="product-wrap">

                    <div class="photo-bor">

                        <img [email protected]("Photo") width="204" height="121" alt="@node.GetProperty("PhotoAltText")" /></div>

                    <div class="photo-sadow">

                    </div>

                    @node.GetProperty("PhotoText")

                </div>

     

        }

     

    }

Please Sign in or register to post replies

Write your reply to:

Draft