I’m trying to understand how you guys are using this - in particular, Masuga.. Let me get this straight. I have a haystack, and I designate my needle terms.. These needle terms can be inside a weblog entry body like so {needle1} and I can actually replace needle1 with a weblog custom field wrapped in code? For example, an image link inside the field processed with Image Sizer? When the weblog entry is viewed, {needle1} would be replaced with the content as mentioned above?
You are absolutely correct. If I’m “injecting” an image or a PDF into the middle of, say, a large textarea, I just make sure to tell the user via the field instructions to add the tags somewhere in the field.
I use it in one case to drop a google map right in the middle of a big block of text that we couldn’t really break up into two separate chunks (text_field_1 - map - text_field_2 just wasn’t ideal). Instead of the client having to paste a big nasty google map link in the middle of the field, I have a separate custom field that uses Huot’s Geo extension. The client drops a {google_map} tag in the correct place in the textarea, and then the map is rendered perfectly, right in the middle of the textarea content, on the template side.
For the record, I also use it with Lumis’ Image Sizer plugin, similar to how you mention above, including {if} conditionals and everything.
This is very, very cool plugin and I think it’s totally underrated. Have fun!
Thanks for the clarification mate! I’ll be sure to incorporate this into the mix somehow! Yes, definitely under-rated! I’m quite surprised it hasn’t received more notice actually.. This is actually something I’ve been DYING to have to improve workflow and to improve accessibility for more social-centric sites I’d have on the plate.
how do that with LG Replace?
goal: insert Notes inside Body on the final front end render
example: Publish Forms Body Form —————————————— I have a {notes}
Notes Form —————————————— car
DESIRE RESULT ON FRONT END: I have a car
how do that??
how do that with LG Replace? 1. create 2 custom fields: Body and Notes 2. on Publish Form fill Body with text 3. on Publish Form fill Notes with text goal: insert Notes inside Body on the final front end render example: Publish Forms Body Form —————————————— I have a {notes} Notes Form —————————————— car DESIRE RESULT ON FRONT END: I have a car how do that??
This is just an example.
{exp:weblog:entries weblog="example"}
<h2>{title}</h2>
{exp:lg_replace:haystack needles="notes"}
{exp:lg_replace:replacement needle="notes"}
{notes_custom_field}
{/exp:lg_replace:replacement}
{body_custom_field}
{/exp:lg_replace:haystack}
{/exp:weblog:entries}
This code will grab the contents of the Notes custom field and place it in the body, where you put {notes}.
how do that with LG Replace? 1. create 2 custom fields: Body and Notes 2. on Publish Form fill Body with text 3. on Publish Form fill Notes with text goal: insert Notes inside Body on the final front end render example: Publish Forms Body Form —————————————— I have a {notes} Notes Form —————————————— car DESIRE RESULT ON FRONT END: I have a car how do that??This is just an example.This code will grab the contents of the Notes custom field and place it in the body, where you put {notes}.{exp:weblog:entries weblog="example"} <h2>{title}</h2> {exp:lg_replace:haystack needles="notes"} {exp:lg_replace:replacement needle="notes"} {notes_custom_field} {/exp:lg_replace:replacement} {body_custom_field} {/exp:lg_replace:haystack} {/exp:weblog:entries}
THANKS!!!!! IT WORKS AMAZING! THANKS Macrike!!!!
Here’s how I got this extension to work with the TEH Textile extension and the Textile plugin.
Basically there are two things you have to do to make this work. First, since Textile already uses curly braces to write inline style, wrap your needle in parentheses and curly braces in your post. {(needle)} If you’re also using the TEH extension for your entries, you also need to tell the extension to ignore things by wrapping it with “=”, like this: ={(needle)}=.
Then you must change the html entities created by Textile back to curly braces. In the Textile plugin code just before the return of function Textile (about line 177) add this:
// reset lg_replace tags when using extension and plugin
$text = str_replace(array('{(', ')}'), array('{', '}'), $text);
$text = str_replace(array('={', '}='), array('{', '}'), $text);
$text = str_replace(array('{', '}'), array('{', '}'), $text);
This also takes out the paragraph tags added by Textile to allow things like floated images, etc. If your content needs to be in a paragraph, just wrap the “replace” content with paragraph tags.
Then you can wrap the exp:lg_replace stuff around the “textiled” content. Quick and dirty but everything works fine. For me anyway. As always, YMMV.
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
Hi there,
I was wondering if it’s possible to add support for parameters on the needles. I want to display some images in a post, and my current solution is something like this:
{exp:weblog:entries weblog="feature" entry_id="{segment_3}"}
{exp:lg_replace:haystack needles="img1|img2"}
{exp:lg_replace:replacement needle="img1"}
{exp:gallery_extended:entries gallery_name="reportajes" entry_id="{img1_id}" limit="1" related_id="{entry_id}" type="weblog" dynamic="off" disable="member_fields|date_fields"}
<div class="image">
{exp:imgsizer:size src="{image_url}" width="598" quality="80"}
{sized}
{/exp:imgsizer:size}
{caption}
</div>
{/exp:gallery_extended:entries}
{/exp:lg_replace:replacement}
{exp:lg_replace:replacement needle="img2"}
{exp:gallery_extended:entries gallery_name="reportajes" entry_id="{img2_id}" limit="1" related_id="{entry_id}" type="weblog" dynamic="off" disable="member_fields|date_fields"}
<div class="image">
{exp:imgsizer:size src="{image_url}" width="598" quality="80"}
{sized}
{/exp:imgsizer:size}
{caption}
</div>
{/exp:gallery_extended:entries}
{/exp:lg_replace:replacement}
{body}
{/exp:lg_replace:haystack}
{/exp:weblog:entries}
I’ve got four custom fields ({img_id}) where I write the ID of the gallery entry, and everything displays correctly. But I think it would be much better if I could do something like this:
{exp:weblog:entries weblog="feature" entry_id="{segment_3}"}
{exp:lg_replace:haystack needles="img1|img2"}
{exp:lg_replace:replacement needle="img1"}
{exp:gallery_extended:entries gallery_name="reportajes" entry_id="{img_id}" limit="1" related_id="{entry_id}" type="weblog" dynamic="off" disable="member_fields|date_fields"}
<div class="image">
{exp:imgsizer:size src="{image_url}" width="598" quality="80"}
{sized}
{/exp:imgsizer:size}
{caption}
</div>
{/exp:gallery_extended:entries}
{/exp:lg_replace:replacement}
{exp:lg_replace:replacement needle="img2"}
{exp:gallery_extended:entries gallery_name="reportajes" entry_id="{img_id}" limit="1" related_id="{entry_id}" type="weblog" dynamic="off" disable="member_fields|date_fields"}
<div class="image">
{exp:imgsizer:size src="{image_url}" width="598" quality="80"}
{sized}
{/exp:imgsizer:size}
{caption}
</div>
{/exp:gallery_extended:entries}
{/exp:lg_replace:replacement}
{body}
{/exp:lg_replace:haystack}
{/exp:weblog:entries}
And in the Publish text area, have something like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis enim sit amet lacus. Maecenas venenatis fringilla nunc. Fusce enim ante, imperdiet eget, feugiat et, dictum eleifend, sapien. {img1 img_id="246"} Suspendisse urna. Ut lobortis nisl non augue. Fusce ipsum mi, fermentum nec, convallis sit amet, elementum eget, neque. Vivamus congue. Nullam dictum, mauris sit amet commodo tempor, leo sem porttitor nibh, in interdum justo nisl ac elit. {img2 img_id="468"} Donec vitae erat consequat libero scelerisque dictum. Aenean mauris odio, pellentesque eu, interdum nec, vulputate non, dui.
Like this I could reduce the number of custom fields on the Publish page. In this example I put two images, but a normal feature article contains around 10 images/videos and the list of custom fields is rather long.
What I’m looking for is something like the embed functionality. For example:
{embed=global/header" name="Lorem Ipsum" whatever="1234"}
I hope all of that made sense. :lol:
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.