However, by viewing page source I could see that Textile was indeed converting curly braces to entities (as you said). So, rather than your 3 replacement lines for the plugin code (around line 177), I used only one, built on your model, which looks for the HTML curly brace entities 123 and 125 (each preceded by “” and followed by “;”) and turns them back into the actual braces, as you do. (I’d post the actual code line, but I can’t figure out how to get this forum to let me post entities that display literally. You get the idea.)
Here’s an example of the code Spacewalk is talking about in the previous post - I used this simple solution and it worked for me too. (note, remove the space between & #123 and & #125 in the example below. The space is only there because otherwise the forum marks them up as { }’s.)
// reset lg_replace tags when using extension and plugin
$text = str_replace(array('& #123;', '& #125;'), array('{', '}'), $text);
(note, remove the space between & #123 and & #125 in the example below. The space is only there because otherwise the forum marks them up as { }’s.)// reset lg_replace tags when using extension and plugin $text = str_replace(array('& #123;', '& #125;'), array('{', '}'), $text);
More clever than I. 😊 Thanks for doing that.
Edit: If you want to be able to wrap a div or whatever around your needle when it’s inserted, you may want to keep the third line of the original plugin code mod, the one that strips Textile’s paragraph tags from around the needle.
I may need to modify this plugin to strip paragraph tags from around the needle when using XHTML. Would love to find a way to get XHTML to ignore needles when they’re the only thing on a line - sometimes I’m replacing needles with a div and a bunch of markup that I don’t want wrapped inside a ‘p’ tag.
Here’s an example of the code Spacewalk is talking about in the previous post - I used this simple solution and it worked for me too. (note, remove the space between & #123 and & #125 in the example below. The space is only there because otherwise the forum marks them up as { }’s.)// reset lg_replace tags when using extension and plugin $text = str_replace(array('& #123;', '& #125;'), array('{', '}'), $text);
Awesome, this solved my problems with the textile formatting too. Many thanks!
Wow this is brilliant. It should be noted (if it hasn’t already) that you cannot put the exp:lg_replace:haystack tag inside your exp:weblog:entries loop. You need to surround the entire loop with it.
I’d LOVE the option of stripping paragraph tags around the needle when the field is formatted XHTML (which, for me, it’s almost always going to be when using this plugin). Right now I’m using it to inject an list of other entries into the page and the spacing issues caused by the extra paragraph tag is a problem.
I was having trouble with using both lg_replace and textile, and tried following steps outlined by bhggraphicdesign but with no look.
I’ve just made the most obvious and simple change and it all works fine. Make sure that textile formatting takes place after lg_replace has done it’s replacing. E.g.
{exp:textile}
{exp:lg_replace:haystack needles="myfirst|mysecond"}
{exp:lg_replace:replacement needle="myfirst"}MYFIRST{/exp:lg_replace:replacement}
{exp:lg_replace:replacement needle="mysecond"}MYSECOND{/exp:lg_replace:replacement}
{contents}
{/exp:lg_replace:haystack}
{/exp:textile}
Obvious I know, but just in case anyone makes the same mistake.
I was having trouble with using both lg_replace and textile, and tried following steps outlined by bhggraphicdesign but with no look. I’ve just made the most obvious and simple change and it all works fine. Make sure that textile formatting takes place after lg_replace has done it’s replacing. E.g.Obvious I know, but just in case anyone makes the same mistake.{exp:textile} {exp:lg_replace:haystack needles="myfirst|mysecond"} {exp:lg_replace:replacement needle="myfirst"}MYFIRST{/exp:lg_replace:replacement} {exp:lg_replace:replacement needle="mysecond"}MYSECOND{/exp:lg_replace:replacement} {contents} {/exp:lg_replace:haystack} {/exp:textile}
I’ve used bhggraphicdesign’s fix on a few sites. Did you remove those extra spaces as noted:
(note, remove the space between & #123 and & #125 in the example below. The space is only there because otherwise the forum marks them up as { }‘s.)
Won’t work if they’re still there.
Wow seems this little bugger is still useful for quite a few people. I actually need to use it in my current project so I might give the code a once over to see if I can *easily* add any improvements.
LG Replace is still the only/easiest? way to include images within the text flow of an entry. So given the comment above (and 754 downloads at this time), I’m wondering why this is not available on the Levi Graham addon page or had any updates/improvements.
I may need to modify this plugin to strip paragraph tags from around the needle when using XHTML. Would love to find a way to get XHTML to ignore needles when they’re the only thing on a line - sometimes I’m replacing needles with a div and a bunch of markup that I don’t want wrapped inside a ‘p’ tag.
Masuga, did you ever get around to a resolution for those dreaded ‘p’ tags?
Just wanted to put in another “thank you” for a very useful plug-in. I was trying to get reeposition to work in a conditional and having no luck. Fired this up and no problems - great plug-in - and it looks like I’m only scratching the surface regarding how to use it in a site!
Edit: turns out I’m having some weirdnesses using it in conditionals that I don’t have time now to track down. So don’t quote me on that part 😉
I’ve been using the LG Replace, FF Matrix combo for image uploads into content areas on the last few sites I’ve done. It really is a powerful way to give clients more control over image placement.
This sounds exactly like what I want to do with a current site. Does this work when inserting the FF Matrix combo into a wygwam field?
Quick note to say I have rewritten this plugin for EE2. In the short term you can grab it from Github until I move it to my new site.
Miraculous. Not only does this:
<?php
/* PHP Parse on Input */
global $DB;
$sql = "SELECT title, field_id_26
FROM exp_weblog_titles t JOIN exp_weblog_data d ON t.entry_id = d.entry_id
WHERE t.weblog_id = 8 AND t.status='open'";
$links = $DB->query($sql);
$linkList = '';
foreach($links->result as $link) {
$linkList .= $link['title'] . '|';
}
?>
{exp:lg_replace:haystack needles="<?php echo $linkList; ?>|vanity-url"}
{exp:weblog:entries weblog="site-specific-content" dynamic="off" search:site-key="={embed:site-key}" search:name="{embed:name}"}
{detail}
{/exp:weblog:entries}
<?php
foreach($links->result as $link) { ?>
{exp:lg_replace:replacement needle="<?php echo $link['title']; ?>"}
<?php echo $link['field_id_26']; ?>
{/exp:lg_replace:replacement}
<?php } ?>
{exp:lg_replace:replacement needle="vanity-url"}
{segment_1}
{/exp:lg_replace:replacement}
{/exp:lg_replace:haystack}
Appear to be working, but it replaces the link list values first, and then replaces {vanity-url} within them. Not sure if there’s a more elegant way than PHP set to process on input, but am thrilled this worked so well.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.