Copied to clipboard

Flag this post as spam?

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


  • M N 125 posts 212 karma points
    May 13, 2015 @ 19:34
    M N
    0

    Simple Staff List - Doc Types or Page Content?

    Hi All,

    I've been pouring through videos and forum posts and can't seem to find the best approach.

    I would like to have a page that lists "Staff Members" - I was able to create a "Staff Item" Doc Type and then a page that allowed for that particular Child Node Type.. It works well, and I think would be easy for the client to use vs perhaps the Grid Editor / Content.

    What I can't seem to figure out is how to prevent each of those staff members from having their own page.

    For example -

    http://sweetdomainname.com/staff-members/john-malkovich

    http://sweetdomainname.com/staff-members/bill-murray

    Only looking for http://sweetdomainname.com/staff-members

    And further, should I be using the typical "umbracoNaviHide" to prevent them from displaying in my navigation? Any help appreciated, i just want a way to store objects and use them on a page. Not have each object be a page of its own. Should I just use a Page Editor / Grid System? (probably grid so the client doesn't totally destroy the layout :)  )

     

    Hope that makes sense - thanks in advance fellow braco's!

     

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    May 13, 2015 @ 20:11
    Chriztian Steinmeier
    101

    Hi M N - welcome to Our!

    If you're using Umbraco 7.2.x have a look at the Nested Content data-type - it could be used exactly for this purpose.

    I've always used the other approach - but I've also always wanted the possibility of having a specific page per Person at some point. What you could do was to not have any templates allowed for the Staff Item type and then not render them in any navigations etc.

    /Chriztian

  • Brian Hvarregaard 21 posts 61 karma points
    May 13, 2015 @ 20:42
    Brian Hvarregaard
    0

    Maybe i misunderstand the problem you are trying to solve. But from what i understand you want a simple container with a dynamic content where the staff members dont have their own site, but is rendered all on the page?

    Every time you have a template you have a new page. My approach would be to create a document type with no template. Then (like it sounds like you already did) make the Document Type hierarchy so you can add the staff members to a page. The parent page that should hold the staff members should have a template, and be allowed to have child items of the staff Document type.

    In the staff members template simply traverse all the children (the staff) and output the HTML that renders the layout of the staff member. You can do this with a Partial View if needed where you pass the Staff node.

  • M N 125 posts 212 karma points
    May 13, 2015 @ 21:03
    M N
    0

    Hi Chriztian,

    Thanks for the quick reply - This extension is pretty awesome. Just installed it and have it working nicely. 

    I really liked the idea of being able to expand the "Staff Members" content item and see all the Staff with an appropriate icon. Really great for the client to understand, but oh well this works really great for a small amount of staff members and maybe it's best not to clutter up the tree anyway :)

    I will say that their PDF rendering example didn't work

    var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>> ("staffMembersList");
           
        foreach(var item in items) {
            <h3>@item.GetPropertyValue("firstName")</h3>
        }

    This simply doesn't work (from inside a Razor master anyway), so I changed it to this

    var items = CurrentPage.GetPropertyValue<IEnumerable<IPublishedContent>> ("staffMembersList");
           
        foreach(var item in items) {
            <h3>@Umbraco.Field(item, "firstName")</h3>
        }

    And all works - even obeys the sort order.

     

     

    Brian,

    I really appreciate your comment as well, that is essentially what I was trying to do... Just out of curiosity, does this Doc Type structure look ok to you as far as what I'm trying to do?

    + Base Page

         - Content

         - Content - Staff Item

         - Home Page

    + Staff Item  (has no template, yet i am still able to view Staff items http://xyz.com/staff-members/jack-nicholson

     

     

     

     

  • Brian Hvarregaard 21 posts 61 karma points
    May 13, 2015 @ 21:09
    Brian Hvarregaard
    0

    For my approach to work you need a container with a template (the staff members page is this container). Like this:

    + Front page

    + About page

    + Other page

    + Staff members (Doc type + template that loops children)

    -- Jack Nicholson (no template, data is rendered in parent)

    -- Tom Cruise (no template, data is rendered in parent)

    -- John Doe (no template, data is rendered in parent)

    -- Jane Doe (no template, data is rendered in parent)

     

    The code in the staff members should be something like this (sry from memory so it wont compile)

    <h2>All staff Members</h2>

    @foreach(var staffMember in Model.Content.Children)

    {

      <p>@staffMember.GetPropertyValue("StaffName", "")</p>

    }

  • M N 125 posts 212 karma points
    May 13, 2015 @ 21:35
    M N
    0

    Ahh brilliant - I think Umbraco was just caching the template before, it all makes sense now.. Thanks so much Brian/Chriztian. I now have your suggested approach as well as Chriztian's working great.. Hard to say which will be easier on the client, but I now I get a 404 page for http://xyz.com/staff-members/jack-nicholson with your approach which is music to my ears!

    Lastly, to prevent them from showing in the navigation, I'm checking TemplateId .. Is that an accepted approach? Below snippet for a general bootstrap nav/sub nav

    It works - just want to make sure it's "OK"

    @{  // I keep this at the top of my Templates
        var homeNode = CurrentPage.AncestorsOrSelf(1).Last();
    }

                      @foreach (IPublishedContent node in homeNode.Children.Where("Visible"))
                        {
                            <li>
                                @if (node.Children.Any(a=>a.TemplateId > 0))
                                {
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">@node.Name<span class="caret"></span></a>
                                    <ul class="dropdown-menu" role="menu">
                                        @foreach (var subNode in node.Children.Where(a=>a.TemplateId > 0))
                                        {
                                            <li><a href="@subNode.Url">@subNode.Name</a></li>
                                        }
                                    </ul>
                                }
                                else
                                {
                                    <a href="@node.Url">@node.Name</a>
                                }
                            </li>
                        }

Please Sign in or register to post replies

Write your reply to:

Draft