Copied to clipboard

Flag this post as spam?

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


  • Torben Warberg Rohde 35 posts 89 karma points
    Dec 19, 2013 @ 13:31
    Torben Warberg Rohde
    0

    Is umbraco.NodeFactory still the way to go for user controls?

    It's been a long time since I have developed Umbraco solutions.... Last time I did it, I used umbraco.presentation.nodeFactory, which is now replaced by umbraco.NodeFactory.

    But having worked a bit with Razor in partial views, I'm wondering if there is also a way to use the whole DynamicNode / IPublishedContent in user controls as well.

    This would give a more uniform codebase for the solution, and make easier to mantain.

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Dec 19, 2013 @ 13:39
    Jeroen Breuer
    0

    Hello,

    In UserControls it's also best to use IPublishedContent. You can probably inherit from UmbracoUserControl which has all the helpers you need to use IPublishedContent.

    Jeroen

  • Torben Warberg Rohde 35 posts 89 karma points
    Dec 19, 2013 @ 14:01
    Torben Warberg Rohde
    0

    Thanks. Does anyone have an example of how to get hold of some content. In my partial view I use Model.Content, but I can't seem to get hold of any object for getting the current page, or instantiating one e.g. from an ID.

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Dec 19, 2013 @ 14:03
    Jeroen Breuer
    100

    If you inherit from UmbracoUserControl you have access to the UmbracoHelper (called Umbraco) so you can do Umbraco.AssignedContentItem to get the current node.

    Jeroen

  • Torben Warberg Rohde 35 posts 89 karma points
    Dec 19, 2013 @ 14:11
    Torben Warberg Rohde
    0

    Aha, "Umbraco" is the magic word. Thanks :-)

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Dec 19, 2013 @ 14:24
    Jeroen Breuer
    0

    Hello,

    Could you please mark a post as the solution if it helped you.

    Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies