Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Change main category names

Quote Reply
Change main category names
Hi,

I have a problem with the categories.
E.g. with categories like this
cars
cars/vw
cars/bmw

If I change the category cars to car. The
subcategories stays the same. Is there a
easy way to change all the subcategories
all at once.

Martin Kjeldsen


Quote Reply
Re: Change main category names In reply to
Hi Martin,

one way would be to do it via sql-monitor, but I don't know the sql statement ( you can use regexp in sql see http://www.mysql.com/...hp?section=Reference )

an other way would be to export the categorys in file, use an editor like ultaedit or MS Excel and do a replace search. Then import the categorys again.

or, I'm not shure if it works , use MYSQLman (http://www.gossamer-threads.com/...s/mysqlman/index.htm )

regards, alexander

Quote Reply
Re: Change main category names In reply to
You need to execute an SQL query such that:

Code:
update Category
Set Name = replace (Name, 'old_string', 'new_string')
where Name RLIKE '^old_string'
This only works if the string you are replacing is unique (since there is no way to anchor the replacement).

So, you'd replace something like

Cars
Cars/VW
Cars/BMW

with 'Car' by using

Code:
update Category
Set Name = replace (Name, 'Cars', 'Car')
where Name RLIKE '^Car'
This would _not_ work on a title like:

Cars/Electric Cars

Since that would get replaced with:

Car/Electric Car


I've only replaced sub and sub-sub cagegories, so I was replacing a string like:

Level1/Level2/Level3

With

Level1a/Level2a/Level3a

And the odds of hitting that sort of reproducing pattern were small.

I don't see a regex based replacement within the SQL language, but maybe someone else knows of one.

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Change main category names In reply to
Oh, you can have a lot of fun with regex in the WHERE Statement.

See http://www.mysql.com/...l.php?section=Regexp

regards, alexander