Nesting with the EE find and replace plugin
Posted: 24 June 2008 05:45 AM   [ Ignore ]  
Summer Student
Total Posts:  24
Joined  05-23-2008

This topic has kinda been discussed in http://expressionengine.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… :-(

Profile
 
 
Posted: 25 June 2008 03:48 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  24
Joined  05-23-2008

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}

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 62588 Total Logged-in Users: 26
Total Topics: 77048 Total Anonymous Users: 11
Total Replies: 416158 Total Guests: 121
Total Posts: 493206    
Members ( View Memberlist )