Copied to clipboard

Flag this post as spam?

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


  • Ault Nathanielsz 87 posts 407 karma points c-trib
    Oct 15, 2019 @ 13:43
    Ault Nathanielsz
    0

    Templating Question: (partial views for use in Doctype Grid Editor) How do I jump back up to the page model from within a partial

    How do I jump back up to the page model from within a partial that is typed to the doctype that is included in the grid?

    Goal: I want to be able to use a "List Children" doctype using the grid editor.

    • The doctype is called: ChildrenListFeature
    • The element doctype consists of a single field called: ChildrenListFeatureTitle

    If I begin with the declaration: @inherits Umbraco.Web.Mvc.UmbracoViewPage<ChildrenListFeature>

    I can then use Model.ChildrenListFeatureTitle as one would expect.

    However, I cannot then use foreach (var varPage in Model.Children).

    Any thought on how best to access the children of the page the DTGE is on?

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Oct 15, 2019 @ 19:36
    Paul Seal
    0

    Hi Ault What about adding a content picker to pick the page to start from? I think you can use xpath to say something like $current to default it to the current node.

    Then you could easily iterate through its children.

  • Ault Nathanielsz 87 posts 407 karma points c-trib
    Oct 16, 2019 @ 10:38
    Ault Nathanielsz
    0

    I want to avoid the tautology of making the user pick the same page to which they are adding the doctype/grid.

    hmmm... I wonder what all of the overloads of GetGridHtml are? ... could there be something there?

    (EDIT: No, there does not seem to be)

  • PamelaBrown 3 posts 73 karma points
    Oct 16, 2019 @ 19:19
    PamelaBrown
    0

    Have you checked everything? I have no idea of where and when was everything submitted. And how everything works.


    https://themesurface.com/wordpress/how-to-create-a-separate-page-for-blog-posts-in-wordpress/

  • Amir Khan 1284 posts 2741 karma points
    Oct 16, 2019 @ 20:24
    Amir Khan
    1

    Umbraco.AssignedContentItem will give you the context of the page the editor is on (at least with a LeBlender grid editor)

    @{
        var hostPage = Umbraco.AssignedContentItem;
    }
    
    @foreach(var childPage in hostPage.Children) {
        <p>@childPage.Name</p>
    }
    
  • Ault Nathanielsz 87 posts 407 karma points c-trib
    Oct 17, 2019 @ 08:03
    Ault Nathanielsz
    1

    Excellent answer!!!

    For future reference - this worked with doctype grid editor in 8.1.5.

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Oct 17, 2019 @ 10:24
    Paul Seal
    0

    Great, I'm glad this worked. I really like your idea of adding a grid type to render the children. I can see it working in the side nav or something if you have a 2 column layout etc

Please Sign in or register to post replies

Write your reply to:

Draft