Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sean Dooley 289 posts 528 karma points
    Feb 01, 2012 @ 10:40
    Sean Dooley
    0

    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?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 01, 2012 @ 10:46
  • Rodion Novoselov 694 posts 859 karma points
    Feb 01, 2012 @ 11:34
    Rodion Novoselov
    0

    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?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 01, 2012 @ 11:38
    Jeroen Breuer
    0

    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());

    model.Children.Where("umbracoNaviHide")

    Jeroen

  • Rodion Novoselov 694 posts 859 karma points
    Feb 01, 2012 @ 11:45
    Rodion Novoselov
    0

    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.

  • Sean Dooley 289 posts 528 karma points
    Feb 01, 2012 @ 12:39
    Sean Dooley
    0

    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?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 01, 2012 @ 12:47
    Jeroen Breuer
    0

    Yes you need the umbraco.MacroEngines.dll. Maybe also the umbraco.dll. I usually just add a lot of references :p.

    Jeroen

  • Rodion Novoselov 694 posts 859 karma points
    Feb 01, 2012 @ 12:47
    Rodion Novoselov
    0

    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)

Please Sign in or register to post replies

Write your reply to:

Draft