Copied to clipboard

Flag this post as spam?

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


  • Andy Felton 185 posts 484 karma points c-trib
    Feb 05, 2020 @ 15:41
    Andy Felton
    0

    Getting Model for containing page

    Hi,

    I'm wondering if anybody is able to help with the easiest way to access the Model of the page which holds the grid within the view (or Grid Value Converter) for the Editor?

    Thanks Andy

  • Anders Bjerner 487 posts 2989 karma points MVP 8x admin c-trib
    Feb 05, 2020 @ 18:35
    Anders Bjerner
    1

    Hi Andy,

    There is currently no way this package lets you get the IPublishedContent holding the grid value. So currently the best option is:

    Umbraco.Web.Composing.Current.UmbracoContext.PublishedRequest.PublishedContent
    

    When using this line of code, you will however make the assumption that the requested page is also the one holding the grid value - which may not always be the case.

    I'd like to make this easier in a future release, and have already made some of the work:

    https://github.com/skybrud/Skybrud.Umbraco.GridData/blob/dev/interfaces/src/Skybrud.Umbraco.GridData/Models/GridDataModel.cs#L39

    This means that you'll be able to acces the parent IPublishedElement of the page or element holding the grid value. I don't really have a plan for when this will be released, but hopefully soon ;)

  • Andy Felton 185 posts 484 karma points c-trib
    Feb 13, 2020 @ 17:44
    Andy Felton
    0

    Hi Anders,

    Thanks for the code works OK for what I'm doing.

    The change you're looking at making would be really useful.

    Thanks Andy

Please Sign in or register to post replies

Write your reply to:

Draft