If you want to use DynamicNode in a Razor template, do NOT @using umbraco.MacroEngines as that will cause a name collision with Razor which will then look for global::RazorEngine.Templating in... umbraco.MacroEngines.RazorEngine.Templating (missing the global::).
Instead, @using ume = umbraco.MacroEngines and then refer to ume.DynamicNode.
Also, the following SiteMap look works quite well, yet noone has suggested it.
@helper traverse(dynamic node, int pad) {
<div style="padding-left: @(pad)px;">
@node.Name @foreach (var n in node.Children) { @traverse(n, pad + 8) } </div> } @traverse(Model, 0)
the reason I added a lambda to it was to be able to filter out stuff like hidden nodes + be able to sort by name. And ul/li's is just the way I'm used to. :-)
Razor SiteMap
This is a followup to http://our.umbraco.org/forum/developers/api-questions/16034-Razor-@helper-in-Umbraco.
If you want to use DynamicNode in a Razor template, do NOT @using umbraco.MacroEngines as that will cause a name collision with Razor which will then look for global::RazorEngine.Templating in... umbraco.MacroEngines.RazorEngine.Templating (missing the global::).
Instead, @using ume = umbraco.MacroEngines and then refer to ume.DynamicNode.
Also, the following SiteMap look works quite well, yet noone has suggested it.
Is there a reason? Performances? Something else?
Hi Stephen! Nice one,
the reason I added a lambda to it was to be able to filter out stuff like hidden nodes + be able to sort by name. And ul/li's is just the way I'm used to. :-)
Good with the DynamicNode-workarond!
Regards,
Jonas
There should be a way to do in node.Children.Where(foo == 2).OrderBy(n => n.Name) or something equivalent.
There are patches in the queue to help, I think. Wait and see...
is working on a reply...