Copied to clipboard

Flag this post as spam?

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


  • Tom 24 posts 69 karma points
    Oct 09, 2013 @ 12:42
    Tom
    0

    How do I render the widgets on a page?

    TL;DR How do you render a content item by Node Id.

    I'm using Widget Grid admin extension for Umbraco to configure a content manageable widget area and I'm stuck trying to render the configured widgets.

    I have a list of node id's that I want to render on the page but I can for the life of me work out how to do this.

    Any guidance is greatly appreciated, its driving me crazy, it must be easy and im missing something! Thanks.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Oct 09, 2013 @ 13:34
    Matt Brailsford
    1

    Hi Tom,

    I tend to grab the nodes, then render using a partial named after the doc type alias passing in the node as model. Something like:

    var nodes = Umbraco.TypedContent(listOfIds);
    foreach(var node in nodes){
        @Html.Parial("Partials\Widgets\" + node.DocumentTypeAlias, node)
    }
    

    (Note, working this way, my widgets don't have a template defined against them, I just hook them up manually)

    I think Lee Kelleher knows a way to render an entire page along with it's template though if you want to go that route. I'll ping him this URL and see if he can shed any more light on the subject.

    Hope that helps

    Matt

  • Tom 24 posts 69 karma points
    Oct 09, 2013 @ 14:25
    Tom
    0

    Thanks for the reply, how do you get the list of Id's out of the Widget Grid property?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Oct 09, 2013 @ 16:41
    Matt Brailsford
    0

    Hi Tom,

    Check this thread a couple of posts down where I show a code snippet for just that:

    http://our.umbraco.org/projects/backoffice-extensions/widget-grid/bugs,-feedback-and-suggestions/43856-Umbraco-6-compatibility

    Many thanks

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft