Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm trying to get macro content in one of the api methods using:
Current.UmbracoHelper.RenderMacro("macroalias");
but getting an error:
Cannot return the IPublishedContent because the UmbracoHelper was not constructed with an IPublishedContent.
Can someone please point me the correct way?
For those who has the same issue or will ever have...
Not sure if it's the best way, but i've created new instance of UmbracoHelper and that helped:
UmbracoHelper helper = new UmbracoHelper(umbPage, Umbraco.TagQuery, _dicFactory, _compRenderer, Umbraco.ContentQuery, Current.UmbracoHelper.MembershipHelper);
where _dicFactory and _compRenderer are injected to existing api controller...
public UmbracoContentApiController(ICultureDictionaryFactory dicFactory, IUmbracoComponentRenderer compRenderer) { _dicFactory = dicFactory; _compRenderer = compRenderer; }
Then you can easily render macro using:
var macro = helper.RenderMacro("MacroAlias");
Thanks, this saved my day!!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to get macro content in UmbracoApiController v8
Hi,
I'm trying to get macro content in one of the api methods using:
Current.UmbracoHelper.RenderMacro("macroalias");
but getting an error:
Cannot return the IPublishedContent because the UmbracoHelper was not constructed with an IPublishedContent.
Can someone please point me the correct way?
For those who has the same issue or will ever have...
Not sure if it's the best way, but i've created new instance of UmbracoHelper and that helped:
where _dicFactory and _compRenderer are injected to existing api controller...
Then you can easily render macro using:
Thanks, this saved my day!!
is working on a reply...