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
    May 15, 2013 @ 17:58
    Fuji Kusaka
    0

    IsLast()

    Anyone has any clue why IsLast() is not working here in DynamicNode ?

    foreach(dynamic f in fd.ChildrenAsList.Where(x=>x.GetProperty("umbracoNaviHide").Value !="1")){
    if(f.IsLast()){ @:{ image: '@f.GetProperty("sliderImages").Value'},
    } else{
    @:{image:'@f.GetProperty("sliderImages").Value'}
    }
    }

    //fuji

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    May 15, 2013 @ 18:38
    Anthony Dang
    0

    It's because it's a linq extension method.

    Extension methods are not wired up on dynamic objects.

    use var instead of dynamic, or explicitly DynamicNode

  • Fuji Kusaka 2203 posts 4220 karma points
    May 15, 2013 @ 20:13
    Fuji Kusaka
    0

    when using var it gives me an error on saving the file

    CS1061: 'umbraco.MacroEngines.DynamicBackingItem' does not contain a definition for 'IsLast' 
  • Fuji Kusaka 2203 posts 4220 karma points
    May 15, 2013 @ 21:11
    Fuji Kusaka
    0

    Try this as well but still the last item is being passed

    DynamicNode m = new DynamicNode(f);
                  f(m.IsLast()){
                      @m.Name
                   }

     

  • Fuji Kusaka 2203 posts 4220 karma points
    May 15, 2013 @ 22:30
    Fuji Kusaka
    0

    Here is the whole source code if someone can point out why IsHelper IsLast() is not working

    foreach(var fd in VSpecial){
            if(fd.ChildrenAsList.Where(x => x.GetProperty("umbracoNaviHide").Value !="1" &&  x.NodeTypeAlias =="test").Count() > 0){
               foreach(var f in fd){

    if(f.IsLast()){  
        @:{ image: '@f.GetProperty("sliderImages").Value'}
    }                                                         

    else{ 
        @:{image:'@f.GetProperty("sliderImages").Value'},
    }
                                                       
        }
        }                                       
    }
  • Fuji Kusaka 2203 posts 4220 karma points
    May 16, 2013 @ 07:57
    Fuji Kusaka
    100

    My Mistake but finally got it working using DynamicNode itself

     

    if(fd.ChildrenAsList.Where(x => x.GetProperty("umbracoNaviHide").Value !="1" &&  x.NodeTypeAlias =="test").Count() > 0){
     var nodes = ((DynamicNode)fd).GetChildrenAsList.Items.Where(x=>x.GetProperty("umbracoNaviHide").Value !="1");
    foreach(var f in nodes){
    if(f.IsLast()){
    @:{ image: '@f.GetProperty("sliderImages").Value'}
    }
    else{
    @:{ image: '@f.GetProperty("sliderImages").Value'},}
    }
    }  

     

    //fuji       

     

  • Stephen 767 posts 2273 karma points c-trib
    Jun 04, 2013 @ 11:26
    Stephen
    0

    FWIW at the moment the IsFirst(), IsLast() etc methods and properties are somewhat buggy in 6.1 and previous versions. Current working on fixing them, hopefully sometime after CG13 we'll have clean methods.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 04, 2013 @ 11:28
    Fuji Kusaka
    0

    Stephen,

    According to my previous post, i managed to get IsLast() method working here.

Please Sign in or register to post replies

Write your reply to:

Draft