Copied to clipboard

Flag this post as spam?

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


  • Giant Penguin 23 posts 112 karma points
    Aug 03, 2019 @ 16:08
    Giant Penguin
    0

    How casting IPublishedContent to its derived type

    In a macro settings, featuredContent is assigned from a Content picker and it is a IContentPageBase.

    This is my code in the macro view: var content = Umbraco.Content(Model.MacroParameters["featuredContent"]) as IContentPageBase;

    but content is null. How can I get IContentPageBase from the featuredContent param value? Please help!

  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Aug 04, 2019 @ 18:31
    Søren Kottal
    0

    Umbraco 8 or 7?

  • Giant Penguin 23 posts 112 karma points
    Aug 06, 2019 @ 07:40
    Giant Penguin
    0

    It is Umbraco 8, Søren. Is it a dynamic object in the macro then cast it can'r be cast?

  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Aug 06, 2019 @ 10:32
    Søren Kottal
    0

    Umbraco.Content should give you IPublishedContent, which should be possible to cast as the interface from ModelsBuilder.

    Can you shee if Umbraco.Content() without the casting gives you anything?

Please Sign in or register to post replies

Write your reply to:

Draft