Copied to clipboard

Flag this post as spam?

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


  • jam 1 post 21 karma points
    Dec 17, 2013 @ 14:38
    jam
    0

    'Umbraco.Web.Models.RenderModel' does not contain a definition for 'NodeById'

    Hi guys,

     

    I'm fairly new to umbraco and c#, and i'm trying to get children and properties of the children of a specific node,

    but i returns  'Umbraco.Web.Models.RenderModel' does not contain a definition for 'NodeById'

    Here is the code:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @ {

    Layout = null;

    foreach (var page in Model.NodeById(1000).Children.Where(i => i.IsVisible())){

               // do something

          }

    }


      What am i missing? Any assistance would be appreciated

  • Charles Afford 1163 posts 1709 karma points
    Dec 17, 2013 @ 22:28
    Charles Afford
    0

    Yes you are trying to call NodeById but method does not exsist

    What are you trying to do?

    @{

    Layout = "this should be your masterpage and not null

    }

    Your model will be the node in the context of the current page.

    So if i am on the home node the Model will be the home node.

    so i could do things like

    @Model.GetPropertyValue("your alias").value;

    or

    @Model.Name (for the name of the node)

     

    Post again if you need more help :).

  • Jonathan Richards 288 posts 1742 karma points MVP
    Dec 18, 2013 @ 11:19
    Jonathan Richards
    1

    var content = new UmbracoHelper(UmbracoContext.Current).TypedContent(nodeId);//Replace nodeId with node Id that you require

    So I would hope, but not tested

     @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @ {

    Layout = null;

    foreach (var page in (new UmbracoHelper(UmbracoContext.Current).TypedContent(1000)).Children.Where(i => i.IsVisible())){

               // do something

          }

    }

Please Sign in or register to post replies

Write your reply to:

Draft