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:
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.
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).
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:
The rendering of the bodyText line is the one which throws the error. Any help anybody can be provide will be appreciated.
Thanks
Andy
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
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 errorAppreciate all your work on Stacked content!
Thanks
Andy
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 calledPage
(for the current page's content) andItem
(for the Stacked Content's block/content).So you could do this...
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)
Hi Lee,
Thanks that helped loads managed to now sort most issues other than those I've raised issues on gitHub.
Thanks Andy
is working on a reply...