web forms version, macros inserted into page doesn't work
I am using umbraco 6.1.3 and the web forms version of uBlogsy. I developed a basic hello world web forms user control, which I turned into a macro. When I insert the macro into the page in the back office via tinyMCE editor, the page loads the macro with its initial viewstate, but no further server side processing takes place. I needed to modify the Page template, specifically the part that renders the content on the page. Here's what I have, but I'm not sure if it's exactly right. also, here's the forum discussion that led me to this conclusion so far
<asp:Content ContentPlaceHolderID="uBlogsyMain" runat="server">
<umbraco:Macro runat="server" Language="razor">
@if (Model.Ancestors().Any())
{
<ul class="breadcrumb">
@* For each page in the ancestors collection which have been ordered by Level (so we start with the highest top node first) *@
@foreach (var page in Model.Ancestors().OrderBy("Level"))
{
<li><a href="@page.Url">@page.Name</a> <span class="divider">/</span></li>}
@* Display the current page as the last item in the list *@
<li class="active">@Model.Name</li>
</ul>
}
<div class="uBlogsy_content_body">
<[email protected](library.RenderMacroContent(Model.uBlogsyContentBody.ToString(), Model.Id))-->
</div>
</umbraco:Macro>
<!--added this line to display content -->
<umbraco:item field="uBlogsyContentBody" runat="server" />
RenderMacroContent does not execute the page life cycle. I'm not sure if it would be possible to make it do that. But what you did is a valid work-around.
Is there a better way to accomplish inserting a user control macro into a page, then? I am new to umbraco and ublogsy, but I would think using ascx user control based macros would be common for people still using web forms; it's the whole reason I'm using the web forms version of uBlogsy (which now I'm not even sure if I needed to do that, if I could have used umbraco:item to render the content in the razor template version). For uBlogsy to not support inserting user control macros out of the box seemed counter-intuitive to me; I thought it was a problem with my macros at first.
It's a limitation of usercontrol macros. The page life cycle disappears if you try to add it into an RTE which is rendered in a razor macro tag.
From what I've heard, most people will not need to put a usercontrol which requires the page lifecycle into a ublogsy body area.
Your solution is the only way around this issue. I might consider moving the body rte rendering out of the macro. There are other implications though, since I use razor files to call other razor files.
web forms version, macros inserted into page doesn't work
I am using umbraco 6.1.3 and the web forms version of uBlogsy. I developed a basic hello world web forms user control, which I turned into a macro. When I insert the macro into the page in the back office via tinyMCE editor, the page loads the macro with its initial viewstate, but no further server side processing takes place. I needed to modify the Page template, specifically the part that renders the content on the page. Here's what I have, but I'm not sure if it's exactly right. also, here's the forum discussion that led me to this conclusion so far
http://our.umbraco.org/forum/developers/api-questions/43627-user-control-macros-in-umbraco-6?p=0#comment157275
That's correct.
RenderMacroContent does not execute the page life cycle. I'm not sure if it would be possible to make it do that. But what you did is a valid work-around.
Is there a better way to accomplish inserting a user control macro into a page, then? I am new to umbraco and ublogsy, but I would think using ascx user control based macros would be common for people still using web forms; it's the whole reason I'm using the web forms version of uBlogsy (which now I'm not even sure if I needed to do that, if I could have used umbraco:item to render the content in the razor template version). For uBlogsy to not support inserting user control macros out of the box seemed counter-intuitive to me; I thought it was a problem with my macros at first.
It's a limitation of usercontrol macros. The page life cycle disappears if you try to add it into an RTE which is rendered in a razor macro tag.
From what I've heard, most people will not need to put a usercontrol which requires the page lifecycle into a ublogsy body area.
Your solution is the only way around this issue. I might consider moving the body rte rendering out of the macro. There are other implications though, since I use razor files to call other razor files.
Thanks for the clarification, Anthony. The umbraco:item workaround in the webforms version of uBlogsy seems good for my purposes, then.
is working on a reply...