Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Bulk Move of Links From Lower Categories To An Upper Category

Quote Reply
Bulk Move of Links From Lower Categories To An Upper Category
Hi,

I have a Links database with 13 level category structure (a DMOZ mutation) and I want to convert into a 5 level structure without losing any lower level links. So, I want to bulk move all links in categories 6 to 13 into the parent level 5 category.

I've researched related topics in the forums and written a restructure script that does the bulk link moves and cleans up the lower level categories.

I would appreciate if anyone can foresee any problems with the process outlined below. I will be testing this out on an offline database installation first.

The strategy is to start at level 13 and move links into the parent category and then repeat the process up to level 6. After each level is done, the leaf categories with zero links are removed.

One thing I'm still not 100% sure on is whether "nph-build.cgi --repair force=1" will update the [Number_Of_Links] field for *all* categories. This is an important step.

Thanks in advance.

Code:


# Bulk Move of Links From Lower Categories To An Upper Category

#
# Preliminary tasks:
# 1. Check full category names in category structure for any errors.
# Repair before proceeding.
# 2. Update [Level] field (aka depth) of category. (This is a custom field
# used to track a category's depth.)
# 3. Run "nph-build.cgi --repair force=1" to ensure [Number_Of_Links] is updated
# for all categories.
# 4. Update [Has_Children] flags. (This is a custom field used to track
# whether a category is a parent.)
# 5. Remove any categories with 0 links *and* that are not a parent.
# 6. Repeat step 3. - Run "nph-build.cgi --repair force=1".
# 7. Repeat step 4. - Update [Has_Children] flags.

# Bulk move of links:
# 8. Repeat the steps below for category levels starting at 13 up to 6.
# 9. Move all links in current level to it's parent category.
# 10. Repeat step 3. - Run "nph-build.cgi --repair force=1"
# 11. Repeat step 5. - Remove leaf cats with 0 links.
# 12. Repeat step 4. - Update [Has_Children] flags.


Edit:

Btw, I'm doing this on a 2.2.1 database. I'm doing this restructure before I upgrade to GLinks 3 as I assume things get really complicated with the additional Category Tree structures. I don't want to be messing around with the category structure too much after I upgrade to Glinks 3.

Regards,
Peter Puglisi
www.ausfreedom.com
Ultimate Freedom is our game.

Last edited by:

rocco: May 15, 2005, 12:55 AM
Quote Reply
Re: [rocco] Bulk Move of Links From Lower Categories To An Upper Category In reply to
I'm happy to report that the above process worked flawlessly and produced a healthy 5 level structure as intended. Smile

Regards,
Peter Puglisi
www.ausfreedom.com
Ultimate Freedom is our game.