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
    Dec 10, 2018 @ 16:47
    Andy Felton
    0

    Macros & Stacked Content

    Hi,

    I've recently hit an issue when rendering a Document Type used with Stacked Content in the back office. The Document Type has a Rich Text Editor Data Type and on this page uses a macro. When this document type is rendered in the back office I get the following error 'Cannot render a macro when there is no current PublishedContentRequest.'.

    I've solved this recently on a API Controller by creating and attaching my own PublishedContentRequest but am not sure where to go with the back office. The view is as follows:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    
    <div class="@Model.Content.GetPropertyValue("theme") elearning-card">
        <h2>@Model.Content.GetPropertyValue("heading")</h2>
        <div class="card-body">
            @Model.Content.GetPropertyValue("bodyText")
        </div>
    </div>
    

    The rendering of the bodyText line is the one which throws the error. Any help anybody can be provide will be appreciated.

    Thanks

    Andy

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 10, 2018 @ 16:52
    Lee Kelleher
    1

    Hi Andy,

    It sounds like a bug with the Stacked Content previewer, as in there isn't a PublishedContentRequest associated with it.

    It's one of those scenarios that I didn't consider.

    Could you open an issue ticket on our github repo please?

    https://github.com/umco/umbraco-stacked-content/issues

    Thanks,
    - Lee

  • Andy Felton 185 posts 484 karma points c-trib
    Dec 10, 2018 @ 17:27
    Andy Felton
    0

    Hi Lee,

    Thanks for your quick response on this. I've opened the issue for you! Can you think of a work around I can implement until you're able to look at the issue.

    Whilst here I've got a further question:

    Have you any example code showing how to use a generated model for the data type - tried a few ways and don't seem to be able to get it to work. I've inherited from @inherits Umbraco.Web.Mvc.UmbracoViewPage<CourseImageCard> where CourseImageCard is my model and get the error

    Cannot bind source content type Our.Umbraco.StackedContent.Web.PreviewModel to model type papaa_models.CourseImageCard.
    

    Appreciate all your work on Stacked content!

    Thanks

    Andy

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 11, 2018 @ 12:04
    Lee Kelleher
    100

    Hi Andy,

    It's because the Our.Umbraco.StackedContent.Web.PreviewModel model isn't the content itself, (but it does wrap all the values, so yeah, can be confusing).

    The PreviewModel contains 2 properties called Page (for the current page's content) and Item (for the Stacked Content's block/content).

    So you could do this...

    var card = Model.Item as CourseImageCard;
    

    Then you'd have intellisense for it.

    Cheers,
    - Lee

    I'll take a look at the GitHub tickets during the day.
    (cross-linked for future reference)

  • Andy Felton 185 posts 484 karma points c-trib
    Dec 11, 2018 @ 18:31
    Andy Felton
    0

    Hi Lee,

    Thanks that helped loads managed to now sort most issues other than those I've raised issues on gitHub.

    Thanks Andy

Please Sign in or register to post replies

Write your reply to:

Draft