Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 06, 2012 @ 09:14
    Fuji Kusaka
    0

    Display last item from media folder

    Hi Guys,

    I cant seem to figure this out and seems like my IF statement is not working at all. 

    Anyone has any idea why i cant get the last item from my media section to display something different

     var slideshow = Model.MediaById(Model.slider);
        var items = slideshow.Children;
    if(slideshow.NodeTypeAlias == "Folder"){
      foreach(dynamic img in items){       
     if(img.items.IsLast())
     {
      @:{src="@img.umbracoFile"}:
                            }
                            else{             @:{src="@img.umbracoFile" },
                            }
                    }
        }

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 07, 2012 @ 07:47
    Fuji Kusaka
    0

    Even this doesnt work at all

     if(img.items.Last())
                             {
                                      @:{src="@img.umbracoFile"}:
                            }
                            else{
                                @:{src="@img.umbracoFile" },
                            }
                    }

    Any suggestion ?

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 09, 2012 @ 20:30
    Fuji Kusaka
    0

    Just for the record got this working.

    Here is the code if someone has the same issue.

     

     

    if(slideshow.NodeTypeAlias == "Folder"){
                    foreach(dynamic img in items){
     if(img.IsLast()) {
                                @:// do something
                            }
                            else{
                                 @:// something else
                            }
                    }
    }

     

     

Please Sign in or register to post replies

Write your reply to:

Draft