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 162 posts 441 karma points c-trib
    16 days ago
    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 421 posts 2317 karma points MVP 3x admin c-trib
    16 days ago
    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 162 posts 441 karma points c-trib
    1 week ago
    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