Is there a way to do this without manually going through and editing every node?

I actually want to replace a hundred or so deprecated target="_blank" attributes with rel="external" attributes for XHTML 1.0 compliance, but it could be anything - a name, address, etc. Must be a FAQ, but I haven't been able to find any solutions here.

I was expecting an SQL query could do it, against whatever table contains node bodies. Which I thought would be 'node', but it doesn't seem to be. Where do node bodies live?

Comments

nedjo’s picture

UPDATE node_revisions SET body = REPLACE(body, 'rel="external"', 'target="_blank"');

halftone’s picture

Ah, so that is where node bodies are hiding.

Syntax is the other way around - REPLACE(old_text,new_text) but it did exactly what was needed in a fraction of a second. Then I did it again for teasers.

Thanks for your help, job done :)

Regards
Tony Sleep http://tonysleep.co.uk

katherined’s picture

I found this thread because I needed the same thing... only I wanted to replace this character: �

I suppose I should try and figure out where this character came from in the first place. When I moved my database from development to production, my spaces turned into boxes... I thought I'd just replace them with a query like this:
update node_revisions set body = replace(body,'�',' ');

affected rows:0... any ideas would be much appreciated!

--update

SO I figured out what happened... in the phpmyadmin export screen, i didn't select utf-8.

In the actual fields there is still just a space in the database.

So if one were to export the database as iso-8859-1 format, is there any easy way to correct it (asuming you don't catch it right away and can just redo it)?

I had already made changes to some modules and I didn't want to risk screwing anything up by redoing the database. I ended up just droping the node_revisions field, and re-doing it only.