Recent Topics

1 Sep 07, 2008 18:04    

My b2evolution Version: 2.x

I only know enough about SQL to be dangerous.
I want to go through all my blog posts and find all the instances of 'hermit crab' that are both words together and replace it with

<a href="http://crabstreetjournal.com">hermit crab</a>

Is this possible with SQL and what is the query format I need to use to make this magic happen :)

SQL Version 4.122 standard

TIA! xo

3 Sep 07, 2008 21:48

IT WORKED!! OMG I can't even begin to tell you how happy you have made me!!!! I would kiss you if you were here in front of me!!! W00t!!!

Tblue wrote:

Look here: http://blog.urbanmainframe.com/2008/07/mysql-search-replace/

You could try:

UPDATE evo_items__item SET post_content = REPLACE(post_content, 'hermit crab', '<a href="http://crabstreetjournal.com">hermit crab</a>');

and afterwards clear the prerendered items cache (Tools -> Misc in the backoffice).

Be sure to have a database backup!

5 Sep 08, 2008 00:49

Well done,

For other reading this post: this is a valuable trick if you ever move your blog to another domain. All URLs to images are hardcoded in the posts, so they won't be found on your new domain. Using this piece of SQL saves the day.
Example: old blog on 'http://oldblog.com' and now on 'http://newblog.com'. All your images look like

<div class="image_block"><img src="http://oldblog.com/image.gif" alt="" /></div>


Using the SQL:

UPDATE evo_items__item SET post_content = REPLACE(post_content, 'http://oldblog.com', 'http://newblog.com');


makes the images refer to the new domain.

6 Sep 08, 2008 02:38

I hit a small snag.

I tried this on my All Things Crabby blog and it worked. So I had other words I wanted to edit to links. I changed the query and repeated. None of those worked. I mean it said it was successful but when I went to the blog and deleted the rendered cache, the words on the blog had not changed.

So I went to my Forever Purple blog and did the same queries and they ALL worked.

Not sure what might be up with my ATC blog. The caching should be the same right? I have some cookie issues with ATC and it won't let me preview a post. Could the cookie issue be causing this?

7 Sep 08, 2008 02:41

Hi Daethian,

To check you can simply view the source of the page. Is it still old - not changed? View the database of a single post that should be altered (try phpMyAdmin for that). Are you sure you altered the correct database?

Good luck

8 Sep 08, 2008 02:49

Hmm it's working on my laptop so it must have been a cache problem with my desktop computer. FALSE ALARM...eep sorry :oops:

9 Sep 08, 2008 03:02

I thought so, but from here I couldn't tell you were the alarmbells rung ;)

Have fun

10 Dec 30, 2010 16:44

I have another question on this topic.

On my foreverpurple.com site I now have three blogs. On one of those blogs (photos only) I have now realized I should have created a 2010 sub folder in my media folder so that I could better organize my photos and manage them etc. So now I've created that folder but if I moved all the photos into that folder all my photos will be broken.

Can I run a find and replace on just the photo blog posts and how?

Can find and replace work on tags and categories also? I'm a little OCD and I don't think I was consistent. *fret*

11 Dec 30, 2010 17:16

I'd wait 32 hours (GMT), start a 2011 folder and make a note to do better next time ;)

Note : I have /year/month/group-of-photos/images.ext as my organisation for images

¥

12 Dec 31, 2010 18:33

lol I know I know but I didn't know if I was going to do 365 Project again. Sounds like its more trouble than I need to pull this off.

13 Dec 31, 2010 19:11

If you're anal enough then it's doable. Personally I've learnt to concentrate on my shiny new structure and overlook my bloated /media/blogs/foo root files of old ;)

Have a great new Year :D

¥


Form is loading...