Textpattern Forum

You are not logged in. Register | Login | Help

#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

#3 2012-11-14 16:01:35

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,053
Website

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

#4 2012-11-14 17:05:48

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,931
Website

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.org | neme-imca.org | hblack.net | LABS

Offline

#5 2012-11-14 17:37:36

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 468
Website

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

#6 2012-11-14 18:02:39

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,053
Website

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

#7 2012-11-14 22:27:44

gaekwad
Moderator
From: North Cornwall, UK
Registered: 2005-11-19
Posts: 983
Website

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

#8 2012-11-15 15:36:54

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,053
Website

Re: Find & Replace article text common method/faves

Har. There really is a crackington haven just like our methington village

Offline

#9 2012-11-15 15:40:32

gaekwad
Moderator
From: North Cornwall, UK
Registered: 2005-11-19
Posts: 983
Website

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

#10 2012-11-15 17:20:00

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,053
Website

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

Board footer

Powered by FluxBB