Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2012-11-14 15:52:21
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Find & Replace article text common method/faves
Hi all,
By no means new to TXP but strangely never tackled this — how to do a find & replace of text on a mass scale (in articles).
I know there has been discussion and some plugins in the past — but how about something >2008 —
Is there an established common plugin to use or method, or a fave SQL regex query.
Preferably, I’d like to do the search & replace without modifying the Last Modified of the articles.
Thanks
—
Offline
#2 2012-11-14 15:59:11
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Re: Find & Replace article text common method/faves
maybe my search terms should have been ‘search replace’ ;-)
I see there’s a ‘rah’ plugin, seems established – rah_replace http://forum.textpattern.com/viewtopic.php?id=30447&p=1
and also a more advanced fork called pax_grep
faves?
Last edited by ChrisArchitect (2012-11-14 17:23:13)
Offline
Re: Find & Replace article text common method/faves
UPDATE `Textpattern` SET Body=replace(Body,'oldWord','NewWord');
UPDATE `Textpattern` SET Body_html=replace(Body_html,'oldWord','NewWord');
UPDATE `Textpattern` SET Excerpt=replace(Excerpt,'oldWord','NewWord');
UPDATE `Textpattern` SET Excerpt_html=replace(Excerpt_html,'oldWord','NewWord');
I use these four queries because I use the “leave text untouched” setting. There’s prolly an easy way to consolidate this into one line.
Offline
Re: Find & Replace article text common method/faves
I use smd_where_used which is great but if you need to mass replace, Dale’s solution would be the quickest.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Find & Replace article text common method/faves
The TXP pax-grep plug-in looks as though it would help. Did you find it from the pax-grep thread you mentioned. There is also this from Steve Lam. I did use that some time ago Archived, no longer working.
Last edited by joebaich (2012-11-14 17:47:03)
Offline
Re: Find & Replace article text common method/faves
pax-grep is looks very cool. But it filters output via a container tag on the front side rather than permanently effecting article.
Offline
Re: Find & Replace article text common method/faves
mrdale wrote:
UPDATE `Textpattern` SET Body=replace(Body,‘oldWord’,‘NewWord’);
UPDATE `Textpattern` SET Body_html=replace(Body_html,‘oldWord’,‘NewWord’);
UPDATE `Textpattern` SET Excerpt=replace(Excerpt,‘oldWord’,‘NewWord’);
UPDATE `Textpattern` SET Excerpt_html=replace(Excerpt_html,‘oldWord’,‘NewWord’);
+1 for this method. I’ve used it multiple times with character encoding strangeness between databases, it works well.
Last edited by gaekwad (2013-02-09 14:17:54)
Offline
Re: Find & Replace article text common method/faves
Har. There really is a crackington haven just like our methington village
Offline
Re: Find & Replace article text common method/faves
mrdale wrote:
Har. There really is a crackington haven just like our methington village
Too mean, Dale. Too mean.
One of those houses on that photo belongs to Thom Yorke, by the way. He busks at the bar (also in the photo) now and again. I haven’t yet shared my true feelings towards In Rainbows, but it’ll happen. It’ll happen.
Offline
Re: Find & Replace article text common method/faves
OK, gaekwad you’re now a God by association in my books. I’ve listened to enough RH to kill a Rhinoceros.
BTW I actually look like the guy on the lower right of the methington village shot after 5 minutes of coding in Drupal.
CH looks really amazing. I think I may have actually been there as a teenager while staying in Truro. Long narrow steep street (no cars) leading down to the bay? Probably a million towns fit that description… Meanwhile I’m stuck here in Winotown, Washington
Offline
Re: Find & Replace article text common method/faves
mrdale wrote:
Long narrow steep street (no cars) leading down to the bay? Probably a million towns fit that description…
^^^ This. But yes, that’s where I live. The winds can get a little hairy at times (80mph+) but the houses seem to be able to take it in their stride.
Oh, and Seasick Steve lives here, too. He drives a tractor.
Offline
Re: Find & Replace article text common method/faves
mrdale wrote:
UPDATE `Textpattern` SET Body=replace(Body,'oldWord','NewWord');
UPDATE `Textpattern` SET Body_html=replace(Body_html,'oldWord','NewWord');
UPDATE `Textpattern` SET Excerpt=replace(Excerpt,'oldWord','NewWord');
UPDATE `Textpattern` SET Excerpt_html=replace(Excerpt_html,'oldWord','NewWord');
thanks. I have a need to do something along these lines. Where / How does one execute the code?
…. texted postive
Offline