Is this supported via razor to define a macroparameter passing it to a var and then pull it inside the take method.
Here's what i'm trying to do.
@{ var numOfItems = @Parameter.numberOfItems }
@foreach (var item in @Model.Children.Where("umbracoNaviHide != 1").Take(numOfItems))
{ some basic HTML Markup <p>@item.nodeName</p>}
But throws an error :
'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Take". When i change to Take(5) it works, but passing macroparam would be nicer.
yep but not working. This was my first idea passing it as an int but throws that Error loading Razor Script 1.cshtml Cannot implicitly convert type 'string' to 'int'
Issue using Model.Children.Take(var)
Is this supported via razor to define a macroparameter passing it to a var and then pull it inside the take method.
Here's what i'm trying to do.
@{ var numOfItems = @Parameter.numberOfItems }
@foreach (var item in @Model.Children.Where("umbracoNaviHide != 1").Take(numOfItems))
{ some basic HTML Markup <p>@item.nodeName</p>}
But throws an error :
'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Take".
When i change to Take(5) it works, but passing macroparam would be nicer.
Have you tried casting numOfItems as an int?
yep but not working. This was my first idea passing it as an int but throws that
Error loading Razor Script 1.cshtml Cannot implicitly convert type 'string' to 'int'
What about if you use this
That was the solution. OMG just so simple <- slap me around the world :p
Thanks Alex
No problem, sometimes it's hard to forget about Razor, Umbraco, DynamicNodes etc... and just think about good old C#! ;-)
is working on a reply...