Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
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
when using var it gives me an error on saving the file
CS1061: 'umbraco.MacroEngines.DynamicBackingItem' does not contain a definition for 'IsLast'
Try this as well but still the last item is being passed
DynamicNode m = new DynamicNode(f); f(m.IsLast()){ @m.Name }
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'}, } } } }
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'},} }}
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.
Stephen,
According to my previous post, i managed to get IsLast() method working here.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
IsLast()
Anyone has any clue why IsLast() is not working here in DynamicNode ?
//fuji
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
when using var it gives me an error on saving the file
Try this as well but still the last item is being passed
Here is the whole source code if someone can point out why IsHelper IsLast() is not working
My Mistake but finally got it working using DynamicNode itself
//fuji
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.
Stephen,
According to my previous post, i managed to get IsLast() method working here.
is working on a reply...