Copied to clipboard

Flag this post as spam?

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


  • Gibran Shah 69 posts 240 karma points
    May 28, 2019 @ 02:30
    Gibran Shah
    0

    How do list views works?

    Hello,

    I need some help figuring out how list views work.

    Let me begin with this:

    enter image description here

    This is the Personnel content. I've added one list item to it, a Person.

    I take this to mean my document types for Personnel and Person are working, and the Personnel document type successfully incorporates a list view, and the Person document type is successfully added as a child node.

    However, when I run my site and go to the Personnel page, I don't see anything for the Person I created.

    My template for Person looks like this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
      Layout = "Master.cshtml";
      Umbraco.Web.PublishedContentModels.Person person = (Umbraco.Web.PublishedContentModels.Person)Model.Content;
    }
    <p>Nothing to see, but we could make a lesson to display a person</p>
    

    Nothing's being pulled from the Person content but I would think I would at least see "Nothing to see, but we could make a lesson to display a person". Instead I get a blank page (with the title "Personnel" at the top so I know I'm at the Personnel page).

    What else is needed to show something from the list of Persons on the Personnel page?

  • Niels Odgaard 14 posts 155 karma points
    May 28, 2019 @ 06:23
    Niels Odgaard
    100

    Do you want to list all child items? If so you could use Model.Content.Children()

  • Bhawna Jain 17 posts 148 karma points
    May 28, 2019 @ 06:53
    Bhawna Jain
    1

    Hey, you could try something like this and see if anything appears on the page.

     @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Personnel>
     @using ContentModels = Umbraco.Web.PublishedModels;
      @{
    Layout = "Master.cshtml";
      }
     <p>Nothing to see, but we could make a lesson to display a person</p>
     foreach (var item in Model.Children("Person"))
    {
    item.Value("Name")//or any other property which you have in "person" doctype
    }
    
  • Gibran Shah 69 posts 240 karma points
    May 29, 2019 @ 04:07
    Gibran Shah
    0

    Thanks both,

    I managed to get some content showing by doing this:

        @foreach (var person in Model.Content.Children()) {
            var content = Umbraco.Content(person.Id);
            <div class="row" class="personDetails">
                @content.name, @content.title<br/>
                @content.email<br/>
                @content.phoneNumber
            </div>
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft