EEConf 2024 is around the corner! EEConf 2024
Hello,
I want to use imgsizer plugin on images inserted by TinyMCE. It inserts them as a standard image tag …
this/is/the/path.jpg
So I need to turn that into …
{exp:imgsizer:size width="300" src="this/is/the/path.jpg"}
… in order for imagsizer to do it’s magic and then regenerate the original <img> tag.
So I figured I could use the lg_replace plugin to swap the start and end of the img tag for those of the exp:imgsizer:size tag.
However, I’ve tried the following without success.
{exp:lg_replace:haystack needles="<img|.jpg">"}
{exp:lg_replace:replacement needle="<img"}
{exp:imgsizer:size
{/exp:lg_replace:replacement}
{exp:lg_replace:replacement needle=".jpg">"}
.jpg"}
{/exp:lg_replace:replacement}
{body_text}
{/exp:lg_replace:haystack}
I think that the use of “, / and } characters in the needle and replacement text is probably the problem. I thought that escaping them with backslashes might work, but no.
Does anyone have any thoughts on this please.
I was hoping I could use the lg_replace plugin to test whether or not comments are allowed outside the exp:weblog:entries tag. I thought I could store the value for {allow_comments} in the haystack, and then use it in a conditional later on. But I can’t get the conditional to work. Any ideas how to solve my problem?
Here’s the relevant code:
{exp:lg_replace:haystack needles="comments_yes_or_no"}
{exp:weblog:entries limit="1"}
{exp:lg_replace:replacement needle="comments_yes_or_no"}
{allow_comments}
{/exp:lg_replace:replacement}
{/exp:weblog:entries}
{exp:weever}
{exp:comment:entries limit="999" weever="on"}
{if comments_yes_or_no == "y"} -- Insert Reply Button Here -- {/if}
{/exp:comment:entries}
{/exp:weever}
{/exp:lg_replace:haystack}
I thought of adding this into the FieldFrame thread, but determined it would be best suited for here. Is there any chance we can get LG Replace to play nicely with FieldFrame by any chance? FieldFrame can produce new rows of content on demand, so it would be simply swell it LG Replace can somehow interact with it. Where I see this going is especially useful for tutorials, in which a multitude of screenshots/videos would be ideal to present a rich, visual experience for users. Making tons of weblog fields would work, but that certainly doesn’t beat the ease and convenience of FieldFrame Matrix. Cheers, Danny
I’m just playing around now with this and Fieldframe, I’ve setup a matrix with a file uploader and a text area (image and caption)… would be awesome if the client could just insert {image_1} through {image_x} for inserting images to the main content field.
Can’t figure out the right logic though, or if its even possible,
has anyone done this or similar with the plugin?
Have you guys seen this screencast at Vimeo called “ExpressionEngine HowTo: FF Matrix + LG TinyMCE + imgsizer + LG Replace”? That may get you started.
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">{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.
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 😊
Just a quick one to see if you guys might be interested in a Matrix CellType I’ve been working on:
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?
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://ellislab.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. 😊
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.