Copied to clipboard

Flag this post as spam?

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


  • TempleClause 32 posts 248 karma points
    Mar 19, 2015 @ 20:30
    TempleClause
    0

    Render something outside where the macro is called

    Okay I don't know if this is possible at all. Here's my problem. I'm building an one page site.

    I have a template called:

    -Template_Master_OnePage.cshtml
    

    which renders a partial called:

    -Partial_OnePage_Section
    

    This partial loops through all the one page section nodes and renders it. Simplified it would be:

    <section>
          <div class="container">
             Html.Raw(umbraco.library.RenderMacroContent(item.GetProperty("sectionText").Value, item.Id))
          </div>
    </section>
    

    As you can see, inside the container div it also renders macros. Now the problem is one of those macros needs to write something after the container div and before the closing section tag.

    Is this possible? I tried it with sections but it didn't work. I hope you understand what I mean, otherwise please ask. Thanks a lot!

  • TempleClause 32 posts 248 karma points
    Mar 21, 2015 @ 14:00
    TempleClause
    100

    I ended up storing the HTML I need outside the container div in the HttpContext.Current.Items and then reading them out again, and setting them to null again like this:

    Partial:

            @if (@HttpContext.Current.Items["speicalWork"] != null)
            {
                @Html.Raw(HttpContext.Current.Items["speicalWork"])
                HttpContext.Current.Items["speicalWork"] = null;
            }
    

    Macro:

            @HttpContext.Current.Items["specialWork"] = <p>test</p>
    
Please Sign in or register to post replies

Write your reply to:

Draft