Copied to clipboard

Flag this post as spam?

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


  • Justin RW 15 posts 135 karma points
    1 week ago
    Justin RW
    0

    Is it possible to display the current document's content in a macro that has been inserted through the RTE?

    I've a simple CTA macro that editors can insert into a blog article at any point they like. This works well with static content but I'd like to give them the ability to edit the macro's content in the article. I've added a field for 'ctaHeading' to the article doctype and in the macro replaced the static heading with:

    <h2 class="cta-box__heading">@Model.Value("ctaHeading")</h2>
    

    but it doesn't recognise the Model so there's an Error loading Partial View script.

    Normally I'd pass the model in the view when Rendering the macro but in this instance it's inserted inside the RTE so there's no template to edit, apart from the macro itself.

    Is it possible to display the current document's content in a macro that has been inserted through the RTE?

  • Lucas Michaelsen 21 posts 177 karma points
    1 week ago
    Lucas Michaelsen
    100

    Hello Jusin,

    You can get it by doing something like this:

    @{
          var currentPage = Umbraco.AssignedContentItem;
    }
    <h2>@currentPage.Value<string>("ctaHeading")</h2>
    
  • Hirthe 1 post 71 karma points
    1 week ago
    Hirthe
    0

    Normally I'd pass the model in the view when Rendering the macro but in this instance it's inserted inside the RTE so there's no template to edit, apart from the macro itself. tellthebell

  • Justin RW 15 posts 135 karma points
    1 week ago
    Justin RW
    0

    That works. Thanks Lucas.

Please Sign in or register to post replies

Write your reply to:

Draft