Copied to clipboard

Flag this post as spam?

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


  • Steve Brown 125 posts 290 karma points
    Jul 31, 2013 @ 17:12
    Steve Brown
    0

    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

     

    <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" />
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Aug 27, 2013 @ 13:04
    Anthony Dang
    0

    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.

     

     

  • Steve Brown 125 posts 290 karma points
    Aug 27, 2013 @ 16:20
    Steve Brown
    0

    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.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Aug 27, 2013 @ 17:02
    Anthony Dang
    1

    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.

     

     

  • Steve Brown 125 posts 290 karma points
    Aug 27, 2013 @ 17:14
    Steve Brown
    0

    Thanks for the clarification, Anthony. The umbraco:item workaround in the webforms version of uBlogsy seems good for my purposes, then.

Please Sign in or register to post replies

Write your reply to:

Draft