Hmmm. I might be wrong but I thought that /Base and Razor were the horses of completely different colours. What can be the reason of the desire to use Razor to create /Base services?
I think that he wants to use things like Model.Children.Where("umbracoNaviHide") in a /base method which is understandable because it's easier to use than the NodeFactory. This is possible by doing something like this:
dynamic model = new umbraco.MacroEngines.DynamicNode(id); //or dynamic model = new umbraco.MacroEngines.DynamicNode(umbraco.NodeFactory.Node.GetCurrent());
Aha, got it. I'm certain that both the DynamicNode and Dynamic LINQ can be used there - they are just helper classes and by no mean depend on Razor itself anyway.
Jeroen is spot on in saying Razor is easier to use than the NodeFactory. Any idea about what references do I need to add to the project to be able to use this functionality in a /base method?
I'm assuming I need to add a reference to umbraco.MacroEngines.dll?
Yes, it should be enough. Both DynamicNode/NodeList and Dynamic LINQ classes reside there. (By the way the DynamicNode is just quite a simple wrapper around the very NodeFactory that mostly just adds dynamic functionality to it)
Razor in Umbraco /Base... is it possible?
Wondering if it was possible to use Razor in Umbraco /Base, for example, to find a node and iterate through its children
var node = Library.NodeById(id);
foreach(var item in node.Children.Where("umbracoNaviHide") {
@item.Name
}
Is it possible? If so, what references need to be added to a Umbraco /Base project?
Here is a blogpost about Razor and /base: http://cultiv.nl/blog/2011/7/25/razor-vs-base-to-output-json-in-umbraco/.
You can also use the Razor syntax in C#: http://our.umbraco.org/forum/developers/razor/27417-Use-Razor-code-in-UserControl?p=1#comment102639
Jeroen
Hmmm. I might be wrong but I thought that /Base and Razor were the horses of completely different colours. What can be the reason of the desire to use Razor to create /Base services?
I think that he wants to use things like Model.Children.Where("umbracoNaviHide") in a /base method which is understandable because it's easier to use than the NodeFactory. This is possible by doing something like this:
Jeroen
Aha, got it. I'm certain that both the DynamicNode and Dynamic LINQ can be used there - they are just helper classes and by no mean depend on Razor itself anyway.
Jeroen is spot on in saying Razor is easier to use than the NodeFactory. Any idea about what references do I need to add to the project to be able to use this functionality in a /base method?
I'm assuming I need to add a reference to umbraco.MacroEngines.dll?
Yes you need the umbraco.MacroEngines.dll. Maybe also the umbraco.dll. I usually just add a lot of references :p.
Jeroen
Yes, it should be enough. Both DynamicNode/NodeList and Dynamic LINQ classes reside there. (By the way the DynamicNode is just quite a simple wrapper around the very NodeFactory that mostly just adds dynamic functionality to it)
is working on a reply...