We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Nesting with the EE find and replace plugin

Development and Programming

Nirada's avatar
Nirada
24 posts
17 years ago
Nirada's avatar Nirada

This topic has kinda been discussed in http://ellislab.com/forums/viewthread/69672/ but what I am trying to accomplish is a little different…

In a nutshell, I want this to work:

{exp:replace find="\\n" replace="SPACE"}
     {exp:replace find="QUOTE" replace="\\QUOTE"}
          {body}
     {/exp:replace}
{/exp:replace}

However, it doesn’t. It just outputs the string with a literal “{/exp:replace}” at the end. Based on what I read in the thread noted above, this is normal behaviour.

So, my question is whether or not there’s a way to get this plugin to do what I want it to do any other way?

I just need to covert the {body} into a single line (remove all newlines) and escape all double quotes so that it can be safely used in the JavaScript for that cool pop-up balloon thingy in Google Maps.

I also tried this:

{exp:replace find="QUOTE|\\n" replace="\\QUOTE|SPACE" multiple="yes"}
     {body}
{/exp:replace}

…. but it doesn’t seem to want to play… :-(

       
Nirada's avatar
Nirada
24 posts
17 years ago
Nirada's avatar Nirada

If anyone can think of anything, please let me know. For now, I’m resorting to PHP to do what I need to do:

{exp:weblog:entries entry_id="18"}
    <?php
        $string ='{body}';
        $string = addslashes($string);
        $string = preg_replace( "/\n/", '', $string );
        echo "html =\"".$string."\";";
    ?>
{/exp:weblog:entries}
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.