3 of 4
3
LG Replace - A different kind of find and replace *NEW*
Posted: 05 August 2009 05:37 PM   [ Ignore ]   [ # 37 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  312
Joined  01-14-2006

well, if I’m not mistaken this is working and has just blown away my mind with possibilities:

<h1>{title}</h1>

{exp:lg_replace:haystack needles="{page_images}image_{row_count}|{/page_images}"}
    {page_images}    
        {exp
:lg_replace:replacement needle="image_{row_count}"}
            
<div class="foo"><img src="{image_upload}" />{image_caption}</div>
        
{/exp:lg_replace:replacement}
    {
/page_images}

    {page_content}
            
{
/exp:lg_replace:haystack}

My fieldframe matrix is called {page_images}, and within {page_content} the client simply inserts {image_x} where x is the row they want to reference in the fieldframe matrix…

Wow, what an awesome plugin.

 Signature 

Weblog | Agency | @_iain_

Profile
 
 
Posted: 05 August 2009 05:41 PM   [ Ignore ]   [ # 38 ]  
Grad Student
Avatar
Rank
Total Posts:  89
Joined  04-30-2007

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.

 Signature 

Casey Reid // Clear Fire Studios // EE Pro Network // @caseyreid

Profile
 
 
Posted: 05 August 2009 08:20 PM   [ Ignore ]   [ # 39 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  312
Joined  01-14-2006
mdesign - 05 August 2009 05:36 PM

Have you guys seen this screencast at Vimeo called “ExpressionEngine HowTo: FF Matrix + LG TinyMCE + imgsizer + LG Replace”? That may get you started.

Just came across that after I posted the code sample lol

great minds think alike and all that smile

 Signature 

Weblog | Agency | @_iain_

Profile
 
 
Posted: 16 August 2009 09:52 AM   [ Ignore ]   [ # 40 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  312
Joined  01-14-2006

Just a quick one to see if you guys might be interested in a Matrix CellType I’ve been working on:

http://expressionengine.com/forums/viewthread/126430/

 Signature 

Weblog | Agency | @_iain_

Profile
 
 
Posted: 18 August 2009 06:28 PM   [ Ignore ]   [ # 41 ]  
Summer Student
Total Posts:  12
Joined  02-08-2009

Awesome… Wish I had found this last week.  Nicely done

Profile
 
 
Posted: 19 August 2009 02:13 PM   [ Ignore ]   [ # 42 ]  
Grad Student
Rank
Total Posts:  89
Joined  09-18-2008

Having some issues with this, not quite sure why it’s not working. Anyone care to help?

Here’s my template code:

{exp:lg_replace:haystack needles="product_list"}

        {exp
:lg_replace:replacement needle="product_list"}
            {if segment_2
== "citrus"}
                
<ul>
                
{exp:weblog:entries search:product-type="Citrus Solvent" dynamic="off" weblog="products" limit="9999" orderby="title" sort="asc"}
                    
<li>{exp:strip_p}{exp:textile}{title}{/exp:textile}{/exp:strip_p}</li>
                
{/exp:weblog:entries}
                
</ul>
            
{/if}
        {
/exp:lg_replace:replacement}

    
<div id="content">
        
{exp:weblog:entries}
            
<h2>{title}</h2>

            
{content}
        {
/exp:weblog:entries}
        
    {
/exp:lg_replace:haystack}

In the {content} field I’ve put in the {product_list} tag to be replaced, but on output the tag is not replaced as expected.
Am I doing something wrong?
Is it because my {content} field is Textile format?

 Signature 

///////////////////////////////////////////////////////////////////////
+ Fred Boyle
+ nGen Works
///////////////////////////////////////////////////////////////////////

Profile
 
 
Posted: 20 August 2009 12:35 AM   [ Ignore ]   [ # 43 ]  
Grad Student
Avatar
Rank
Total Posts:  56
Joined  12-19-2007

Hey guys, I’m having some problems.

I have 2 custom fields, {main_content} and {main_extended}. I’m using LG Replace, and FF Matrix with my {main_content} and {main_extended} custom fields set to use the JM WYMEditor fieldframe (http://expressionengine.com/forums/viewthread/125927/).

Here’s the issue: If {main_extended} is set to use WYMEditor, the whole page crashes and burns quite spectacularly: http://www.easterlydev.com/about/community-involvement/. It does the same if both {main_content} and {main_extended} use WYMEditor. However, if I set the field type of {main_extended} to straight textarea, all is well.

With the help of Kurt Deutscher (thanks Kurt!) we were able to determine that SOMETHING doesn’t like a closing curly brace in the {main_extended} custom field. Whether that something is LG Replace or WYMEditor, I’m not sure. I’ve posted this in both the LG Replace thread and the JM WYMEditor thread in hopes that someone cleverer than me can figure this out. smile

 Signature 

“The very powerful and the very stupid have one thing in common. Instead of altering their views to fit the facts, they alter the facts to fit their views…which can be very uncomfortable if you happen to be one of the facts that needs altering.” - The Doctor

Profile
 
 
Posted: 20 August 2009 11:50 AM   [ Ignore ]   [ # 44 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  121
Joined  02-16-2005
bhggraphicdesign - 13 March 2009 03:17 PM

Here’s how I got this extension to work with the TEH Textile extension and the Textile plugin.

Thanks for this excellent post, which pointed the way for me. However, my experience was slightly different (and simpler). I’m using the Textile plugin (v.1.1.1 (2.0.0 r2779)) and Textile Editor Helper (TEH) extension 1.2. Maybe the later version of TEH explains the difference in my experience, but I do not need to wrap parentheses or “=” around my needle to get it to work.

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.)

And with that, the LG Replace plugin seems to work just fine with Textile, using a plain old LG Replace needle like {images1}—no “()” or “==” wrapped around it.

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.

Profile
 
 
Posted: 31 August 2009 11:19 PM   [ Ignore ]   [ # 45 ]  
Summer Student
Total Posts:  16
Joined  02-14-2008
spacewalk - 20 August 2009 11:50 AM

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);
Profile
 
 
Posted: 01 September 2009 12:31 PM   [ Ignore ]   [ # 46 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  121
Joined  02-16-2005
adhesion - 31 August 2009 11:19 PM

(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. smile Thanks for doing that.

Profile
 
 
Posted: 11 September 2009 10:16 PM   [ Ignore ]   [ # 47 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006
spacewalk - 20 August 2009 11:50 AM

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.

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 24 September 2009 12:07 PM   [ Ignore ]   [ # 48 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2062
Joined  09-16-2004
adhesion - 31 August 2009 11:19 PM

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!

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 15 November 2009 06:31 PM   [ Ignore ]   [ # 49 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  113
Joined  12-01-2008

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.

 Signature 

benek - web design portfolio
WeddingWise - NZ wedding vendor directory
FotoMaps - put your photos on a map

Profile
 
 
Posted: 10 December 2009 11:08 AM   [ Ignore ]   [ # 50 ]  
Summer Student
Avatar
Total Posts:  9
Joined  05-02-2007

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.

Profile
 
 
Posted: 10 December 2009 01:46 PM   [ Ignore ]   [ # 51 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  467
Joined  09-06-2006
John Ryan - 10 December 2009 11:08 AM

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’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.

 Signature 

Kyle Summer | smartpill design | New Haven, CT |  twitter

Profile
 
 
Posted: 02 January 2010 07:57 AM   [ Ignore ]   [ # 52 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  273
Joined  11-22-2006
Leevi Graham - 09 June 2009 11:19 PM

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.

 Signature 

pfweb.co.uk

Profile
 
 
Posted: 02 January 2010 09:00 AM   [ Ignore ]   [ # 53 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  530
Joined  04-23-2008
mdesign - 11 September 2009 10:16 PM

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?

 Signature 

Danny Tam » Twitter | LinkedIn | Facebook | Flickr

Profile
 
 
Posted: 14 March 2010 10:08 PM   [ Ignore ]   [ # 54 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1917
Joined  01-05-2007

I just picked up on this plugin and wanted to say well done Leevi!

Now get it on your site!

 Signature 

 
Steven Hambleton | Follow me on Twitter!


ExpressionEngine Outsourcing for Marketing, Graphic & Web Agencies
Partner with a professional ExpressionEngine development team to turn your designs into functioning sites.

Profile
 
 
   
3 of 4
3
 
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 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120506 Total Logged-in Users: 62
Total Topics: 126574 Total Anonymous Users: 43
Total Replies: 665457 Total Guests: 331
Total Posts: 792031    
Members ( View Memberlist )