Yes you're right about that. But what happens if you change the number to something else? What happens if you change i to 5? Does it then match every 5th node or what does it match?
Ok...perhaps this is a bug with the implementation? (Of the method in Umbraco, not the way you use it) Think you should try and file an issue at http://issues.umbraco.org/issues
I just found this and was about to create an issue for it as it seems like a pretty obvious flaw in the IsModZero method (it's not much use for modulus > 2).
However in trying to think of what you'd name a helper method that returned the index, I realised there is a GetIndex() method already.
So this might save someone some time in the future:
foreach (var v in blah.Children()) {
@Umbraco.If((v.GetIndex() +1 ) % 3 == 0,"do thing")
}
The offset is the +1 - that's how you can move it.
IsModZero start from node other than 1
I need to add a class to node number 3 6 9.. and so on in a list
Example:
But this applies to node number 1,4,7...
How du i push the mod back or forward?
Hi Claus
How many items are i your list? Isn't it a matter of adjusting the number? What happens if you change it to 5?
/Jan
The number of items in the list shouldnt matter
Example (with bold), It want this:
node
node
node
node
node
node
node
node
node
but the above code does this:
node
node
node
node
node
node
node
node
node
Hi Claus
Yes you're right about that. But what happens if you change the number to something else? What happens if you change i to 5? Does it then match every 5th node or what does it match?
/Jan
Changing
Hi Claus
Ok...perhaps this is a bug with the implementation? (Of the method in Umbraco, not the way you use it) Think you should try and file an issue at http://issues.umbraco.org/issues
/Jan
I just found this and was about to create an issue for it as it seems like a pretty obvious flaw in the IsModZero method (it's not much use for modulus > 2).
However in trying to think of what you'd name a helper method that returned the index, I realised there is a GetIndex() method already.
So this might save someone some time in the future:
The offset is the +1 - that's how you can move it.
It's just doing our own Mod.
is working on a reply...