I have a weird issue here where IsLast() is not working in a loop after making some if statements.
Under my content section i have a folder node under which admin can add multiple nodes each with a specific property Check box. They all have different templates that is 4 different ones depending on the property attributed.
I need to displayable a line under the last content but doesnt seems to be working though
@foreach(var p in projects.Children){ if (p.Where("cibPar") && p.Where("cibNonMau") && p.Where("cibLoc")){ if(p.typeOfProduct == "test" || p.typeOfProduct == "test,test2"){ <li class="@Library.If((!p.IsLast()), "last clearfix","clearfix")"> </li> } } }
Looks like its taking the last node in the folder instead. Not the last node with the same property .
IsLast() not working
Hi Guys,
I have a weird issue here where IsLast() is not working in a loop after making some if statements.
Under my content section i have a folder node under which admin can add multiple nodes each with a specific property Check box. They all have different templates that is 4 different ones depending on the property attributed.
I need to displayable a line under the last content but doesnt seems to be working though
Looks like its taking the last node in the folder instead. Not the last node with the same property .
Any suggestion what i might be doing wrong here ?
We had problems with Last, first etc.. and ended up adding in a counter and comparing against 0 or Children.Count
But here dont know the exact number of nodes the client will be adding. So count will not be a good solution to me
not sure what you mean projects.Children.Count will give the number of nodes added to your projects node???
Here all the templates will be pulling nodes from content folder with id 1111
sorry @Fuji you've lost me...
IsLast() if it was working would give you the last node from projects.Children (eg the last node of your enumeration)
are you wanting the last node from projects.Children filtered as per your ifs?
if so then you need to filter at the enurmeration level... so that your foreach only enumerates through your filtered set...
As you have it you have no way of knowing that the last child of projects will necessarily satisfy your if statements???
Or I could be completely misunderstanding you???
I made a long post, before our.umbraco.org died...
Oh well I'll try again.
With your .IsLast() you are asking if p is the last item in your collection, and it isnt.
You have more items in your collection, that simply doesn't fit your if statements.
What you want to do is trim down your collection so you only have the items in it, that you want to show.
This isn't 100% accurate, but it should give you an idea of what I mean.
is working on a reply...