Copied to clipboard

Flag this post as spam?

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

  • Nicole Polet 50 posts 202 karma points
    Aug 09, 2017 @ 17:50
    Nicole Polet

    Doctype Grid Editor: pulling values from the main page into a grid cell

    I am using Doctype Grid Editor and I have my site set up so that every page uses a "page" doctype, and in the "page" template I render a grid (@Html.GetGridHTML(Model.Content,”myGrid”)). This doctype also includes a boolean property called "hasSidebar".

    Using doctype grid editor, I have it so that every cell in "myGrid" is rendered with a different doctype, each with it's own partial view.

    What I want to do is, in each partial view, find out the value of "hasSidebar" for the page it is being rendered on.

    So basically I think I'm asking if it's possible to pass in values from a parent doctype into a partial view that is being rendered within its template.

    Any help would be greatly appreciated! Thank you!

  • Laurence Gillian 597 posts 1216 karma points
    Aug 09, 2017 @ 18:06
    Laurence Gillian

    Providing your partial view has @inherits UmbracoViewPage at the top , you should be able to use the UmbracoHelper do something like:

        var currentPage = Umbraco.AssignedContentItem; 
    <p>Current page name: @currentPage.Name</p>

    But depending on what your doing, there might be a cleaner way to do it.

  • Nicole Polet 50 posts 202 karma points
    Aug 10, 2017 @ 00:12
    Nicole Polet

    Hmmm, when I use that code, @currentPage.Name returns the name of the grid editor...

    Here's what it looks like in grid.editors.config.js: enter image description here

    It's returning the word "Banner"

  • Arjan Woldring 123 posts 230 karma points
    Jul 18, 2018 @ 13:14
    Arjan Woldring

    Hi Nicole, I'm struggling with the same. Did you find a solution?

    What I'd like to do is traverse up to the root-node. Like Model.Site(). To get some property values.

    Any help is welcome :) Arjan

  • Arjan Woldring 123 posts 230 karma points
    Jul 18, 2018 @ 14:59
    Arjan Woldring

    If anyone has the same issue, I solved it this way.

    var umbracoHelper = new Umbraco.Web.UmbracoHelper(UmbracoContext.Current);

    This will get you the current root-node.

    Cheers, Arjan

Please Sign in or register to post replies

Write your reply to: