Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Oct 16, 2009 @ 18:40
    trfletch
    0

    Run Macro inside RTE that is called from another macro

    Hi, I have an Umbraco V4.0.2.1 website and I am trying to insert a macro into the rich text editor that I want displayed on the page in between some text (the macro calls in an advert image from an external database). The problem is the rich text editor text is being pulled in by another macro that calls a user control, this is because only the first 100 words of the text from the rich text editor is allowed to be displayed unless the user is logged into the website with a valid subscription. This of course is not displaying the advert macro and is instead just showing:

    <?UMBRACO_MACRO macroAlias="Advert-place-holder"
    positiononpage="Verticle Banner" advertid="49" /> 
    

    I have read and understand that you cannot have a usercontrol macro inside another usercontrol macro and I therefore tried to put the code from the user control that displays the RTE content directly into my template but this still did not work.

    Is there anyway I am going to be able to get this to work. Basically what I need is some sort of code whether it be XSLT or ASP.net to display only the first 100 words from the rich text editor unless the user is logged in with a subscription (that means that they are not just a member of the site but are a member and have a specific role). Within the rich text editor I want the end user to be able to insert a usercontrol macro that calls in an inline advert specific for that page. Is there going to any way around this issue that anyone can think of? I hope this all makes sense, please let me know if you need anything explained further, I appreciate any help or suggestions that anyone can offer.

    Many Thanks
    Tony

  • Ron Brouwer 273 posts 768 karma points
    Oct 16, 2009 @ 18:54
    Ron Brouwer
    0

    Hi Tony,

    In your function to limit the length use:

    umbraco.library.RenderMacroContent(input)

    Doing so wil allow you to use Macro's.

    Ron

  • trfletch 598 posts 604 karma points
    Oct 19, 2009 @ 10:10
    trfletch
    0

    Hi,

    Thank you for the response, can you explain a little further what I need to do with the code above? I assume I put it in my usercontrol that limits the article length, does it matter where? Will this allow me to show an advert any in the richtext editor text?

  • Ron Brouwer 273 posts 768 karma points
    Oct 19, 2009 @ 10:35
    Ron Brouwer
    0

    It replaces the

    <?UMBRACO_MACRO macroAlias="Advert-place-holder"
    positiononpage="Verticle Banner" advertid="49" />

    anywhere in your content. So I think you need to use it before limiting your textlengt. You just need to make sure that the advertisement is not cut I think.

    Ron

  • trfletch 598 posts 604 karma points
    Oct 19, 2009 @ 10:50
    trfletch
    0

    Hi Ron,

    Thanks I will give this a try, so I literally just need to add umbraco.library.RenderMacroContent(input) to my usercontrol that limits the text before the code that actually limits the text? I don't need to replace "input" with anything??

  • trfletch 598 posts 604 karma points
    Oct 19, 2009 @ 17:53
    trfletch
    0

    Hi Ron,

    I have tried this and it seems to now output the html from my macro usercontrol but does not run any of the code behind. Any suggestions?

     

  • Ron Brouwer 273 posts 768 karma points
    Oct 20, 2009 @ 00:04
    Ron Brouwer
    0

    Hmm, I forgot that. The function I suggested does not use codebehind.

    The only think I can think of at this time is to use a regular expression to find and load the control yourself using loadcontrol.
    However maybe there are there core developers who have a better idea.
    If so I would also like to know it for myself.

    Sorry I can't be more helpful

    Ron

  • trfletch 598 posts 604 karma points
    Oct 20, 2009 @ 17:47
    trfletch
    0

    Ok Ron,

    Thanks for your help anyway.

    Is there anyone else out there that can offer any suggestions or advice regarding this?

    Can anyone think of another way around the issue?

    Many Thanks

    Tony

Please Sign in or register to post replies

Write your reply to:

Draft