Copied to clipboard

Flag this post as spam?

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


  • Chad Rosenthal 272 posts 474 karma points
    Mar 18, 2011 @ 16:25
    Chad Rosenthal
    0

    Displaying RTE field that has a Macro inside of it.

    I'm trying to create a sidebar widgets module. This would require me to create list of nodes and display their content. The nodes basically have two values, a textbox and a RTE. Inside the RTE, I'm displaying different macros, either Razor or XSLT. 

    Is this possible to do in Umbraco 4.7?

    I'm using @Html.Raw(node.mainContent.ToString()); to display the value from the field. The html is working correctly, but when I view source, I see the following: 

    <?UMBRACO_MACRO macroAlias="Copyright" />

    Thanks!

    -C

     

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Mar 18, 2011 @ 16:37
    Stefan Kip
    0

    Yeah that won't work :-(
    You'd have to use 'umbraco:item': http://our.umbraco.org/wiki/reference/templates/umbracoitem-element

  • Chad Rosenthal 272 posts 474 karma points
    Mar 18, 2011 @ 16:44
    Chad Rosenthal
    0

    So I tried to do this inside my Razor method.

                Item currentItem = new Item();

                currentItem.NodeId = currentNode.Id.ToString();

                currentItem.Field = "mainContent";

    But how do you render it?

    -C

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Mar 18, 2011 @ 17:10
    Stefan Kip
    0

    Well you can use this in your template:

     field="bodyText" runat="server" />

    Or you can create it with code and add it to the Controls collection of a ASP.net PlaceHolder:

    Item currentItem = new Item();
    currentItem.NodeId = CurrentNode.Id.ToString();
    currentItem.Field = "mainContent";
    phSomePlaceHolder.Controls.Add(currentItem);
  • Chad Rosenthal 272 posts 474 karma points
    Mar 18, 2011 @ 17:14
    Chad Rosenthal
    0

    Yeah, that is the code that I had in my old control. I was trying to move the code out of the compiled control and into Razor.

    But at the moment, I can't seem to find out how to render it.

    -C

     

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Mar 18, 2011 @ 17:15
    Stefan Kip
    0

    Well I just gave ya two options... What's the prob?

  • Chad Rosenthal 272 posts 474 karma points
    Mar 18, 2011 @ 17:20
    Chad Rosenthal
    0

    as far as I can tell, neither of these options work when you are in a .cshtml file. Both of those options work when in a .aspx and .ascx file. I'm trying to do all of the code and all of the rendering using Razor.

     

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Mar 18, 2011 @ 17:40
    Stefan Kip
    0

    Sorry, can't help ya then... Haven't played with razor yet unfortunately!

  • Chad Rosenthal 272 posts 474 karma points
    Mar 18, 2011 @ 20:03
    Chad Rosenthal
    1

    Finally found it with the help of the code from http://our.umbraco.org/projects/website-utilities/rndr-url-macro-renderer

    @Html.Raw(umbraco.library.RenderMacroContent(content, currentNode.Id));

    -C

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Mar 18, 2011 @ 20:06
    Stefan Kip
    1

    Nice work mate!

Please Sign in or register to post replies

Write your reply to:

Draft