Copied to clipboard

Flag this post as spam?

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


  • Jay 409 posts 635 karma points
    Nov 04, 2016 @ 16:42
    Jay
    0

    Getting CurrentPage within DittoProcessorAttribute

    Hi All,

    Was wondering if there's any way I can get the CurrentPage (of IPublishedContent) within a DittoProcessorAttribute?

    Do i have to create a processor to pass them in like the one below https://jamiepollock.github.io/blog/2016/06/15/getting-started-with-ditto-processors

    Or is there an easier / quicker way.

    Appreciate all the help

    Thanks

  • Casper 70 posts 308 karma points
    Nov 04, 2016 @ 18:23
    Casper
    2

    In your processor, Context.Content is what you need, as I remember it.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Nov 06, 2016 @ 22:13
    Lee Kelleher
    1

    As Casper says Context.Content will do it.

    However that will contain the reference to whichever IPublishedContent object that Ditto is currently processing.

    If you want the actual "Current Page" (as per the node that matches the URL), then you'd need to go with UmbracoContext, something like this...

    var currentPage = UmbracoContext.Current.ContentCache.GetById(UmbracoContext.Current.PageId.Value);
    

    I use this for when I'm mapping against "fake" IPublishedContent object, like from Nested Content, and I need to get something from the actual current page's content node.

    I hope this helps?

    Cheers,
    - Lee

Please Sign in or register to post replies

Write your reply to:

Draft