Copied to clipboard

Flag this post as spam?

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


  • Lee 1130 posts 3088 karma points
    Oct 01, 2009 @ 07:21
    Lee
    0

    Replacing Text / Tags In Users Input?

    We are doing a mail out and I want to my users to be able to create TAGS in their bodyText which I will auto replace on page view.

    For example - User writes this in a page

    Etiam vel lorem nulla. Nam tristique volutpat pulvinar. Vivamus sed purus arcu. Etiam semper elit a quam tincidunt fringilla. Donec scelerisque eleifend purus et laoreet. Praesent at augue in [TAG:NAME] vulputate viverra ut at au mauris, fermentum in lobortis in, porta eu risus. Nunc pulvinar nunc suscipit lacus lobortis in bibendum tellus aliquam. Mauris convallis ligula id arcu tristique facilisis. Sed [TAG:COMPANY] tempor augue, eget consequat sem blandit id.

    Now I want to be able to replace those tags based on a Querystring value, I did this using a Macro and it sort of worked but the problem is Macro's insert a DIV in the the editor and it screws the bodyText as TinyMCE tries to add / guess where the p tags should go.  So I end up with lots of extra <p> tags when the page is saved, and the client doesn't like the yellow dotted block breaking up the text in the UI.

    any ideas would be greatly apreciated?

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Oct 01, 2009 @ 10:44
    Douglas Robar
    0

    A couple approaches come to mind (there may be others as well)...

    1. In your template where you'd normally have <umbraco:Item field="bodyText" .../>, use a macro instead, such as <umbraco:Macro alias="ExpandTags" field="bodyText" .../>. In the macro you'd basically do a search/replace. This has the advantage of leaving the tags in the source document and if you change the text of any tag it'll be rendered immediately the next time the page is viewed. Depending on the complexity of the replacement and if you want to have the tag name and equivalent lookup field as umbraco nodes (or as umbraco dictionary items), you could write this in xslt or .net.

    2. Create an event handler that does a search/replace on the Publish event (or maybe the Save event). Similar logic to #1 but this will replace the tags with text in the bodyText field itself, which might be handy.

    If these tags need to be replaced as part of a personalized email blast only, let us know. I'm sure I've seen a few blog posts about options to do that as well.

    cheers,
    doug.

  • Lee 1130 posts 3088 karma points
    Oct 01, 2009 @ 17:23
    Lee
    0

    Hey Doug... It is part of a personalised email blast :)

    Need to allow client to add our custom tags where they want them, I'm intrigued in your suggestion 1?  I'll have a play and see if I get stuck - Really appreciate any links for blogs about personalised email blasts?

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Oct 01, 2009 @ 17:36
    Douglas Robar
    0

    Here you go, my friend!

    http://www.nibble.be/?p=63

    Source code is available from Tim if you need to modify it. Be aware that some have reported it doesn't like large email blasts (4500 recipients was noted) but I can't say from personal experience one way or the other.

    And... using Campaign Monitor or MailChimp may be a better choice as they handle the load, bounces, being marked as spam, etc. Inspiration/discussion at http://our.umbraco.org/forum/ourumb-dev-forum/features/2508-Newsletter-and-email-marketing-solution---plugin-for-MailChimp and http://our.umbraco.org/forum/developers/extending-umbraco/3997-Member-Login--Newsletter-subscription-management--blog-users

    Be sure to let us know what you end up with!

    cheers,
    doug.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies