Gossamer Forum
Home : Products : Gossamer Links : Discussions :

[idea] Directory Depth

Quote Reply
[idea] Directory Depth
Just an idea.

Add a column to lsql_Categories called Directory_Depth. This column would measure how deep the category is. For example Travel and Tourism/Lodging/Bed and Breakfasts would have a DD of 3. Tools/Hammers wouuld have a DD of 2. Top Level Categories - 1. Then have all the DD fields updated with each change, just like Number_of_links does.

Why have this?

Many reasons:
  • Calculating cost of advertising in particular category... deeper mean less. Allows automated calcualtion as DD could be part of your formula.
  • Calaculating editor responsibility.. summing up all the DD's and applying this figure to other factors such as number of links and number of categories under an editor's belt.
  • Stats. Listing all categories which have a DD greater than 10 for example. See how deep your directory is getting.
  • Maintenance - Removing categories which are getting too deep.


And so on.

Comments? (Except for: I wish this sooke guy would can it!Wink)


http://www.iuni.com/...tware/web/index.html
Links Plugins

Last edited by:

sooke: May 11, 2002, 11:24 AM
Quote Reply
Re: [sooke] [idea] Directory Depth In reply to
There is a fairly recent module in the GT library called GT::SQL::Tree. It is used in GForum for managing the structure of categories and of posts in a thread. When you want to use this module, you need to have a field in the table which records the depth of your category/post.

Now, why do I tell you all this?

To me, it looks like a very useful module, and if you can get Jason to convince Alex to use it also for Links SQL, you might have what you want without any further ado.

In the meantime, you could of course create the field in the database and write a little script that calculates the depths of all your categories.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] [idea] Directory Depth In reply to
Thanks Ivan, very informative indeed.

Jason and Alex, any comments?

I am not sure I could write a module to do this (especially in Perl!). I lack the ability. And if there is already a module which does this.... why re-invent the wheel if you don't have to.

Thanks for you comments!
Quote Reply
Re: [sooke] [idea] Directory Depth In reply to
Here is your script.

You first have to create a field called "Depth" in the category table (I assume you know how to do that).

Then you can run the script (after changing some paths). The script will put the category depth in the field "Depth". If you want to test it, you can comment the $table->update line a few lines from the end.

Category numbering starts at zero, i.e. top level categories have level zero.

I tested it on my installation and it seems to do what it is supposed to do.

Ivan
-----
Iyengar Yoga Resources / GT Plugins

Last edited by:

yogi: May 11, 2002, 1:48 PM
Quote Reply
Re: [yogi] [idea] Directory Depth In reply to
Wow Ivan!

That was a great suprise. Thank you very, very much! I am going to test...

(Yes I know how to create columns)
Quote Reply
Re: [yogi] [idea] Directory Depth In reply to
The invisible script :)
Quote Reply
Re: [Paul] [idea] Directory Depth In reply to
?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] [idea] Directory Depth In reply to
There was no attachment when I first read the thread...you must have edited your post and added it Smile
Quote Reply
Re: [Paul] [idea] Directory Depth In reply to
Yes, I changed the attachement slightly (twice actually).... you were too fast!

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] [idea] Directory Depth In reply to
I have changed path to perl and Links::init('/s/mysite/cgi-bin/admin');

I am just creating the Depth field.... column type is interger... that went in ok...

I renamed to catdepth.cgi and put into my cgi-bin/depth directory....

When I run it I get an internal server error.
Quote Reply
Re: [sooke] [idea] Directory Depth In reply to
It was meant to run from command line...

Anyway, change "use Links qw/$DB/;" to "use Links qw/$IN $DB/;", and somwhere at the beginning of the main subroutine, add "print $IN->header;"

That should do the job. Also check file permissions (755).

Edit: I have edited the attachement, try the new version (which includes the above changes). Anyway, you might want to change the "print" statement near the end of the file if you use it through your browser (i.e. change \n to <br />).

Ivan
-----
Iyengar Yoga Resources / GT Plugins

Last edited by:

yogi: May 11, 2002, 1:42 PM
Quote Reply
Re: [yogi] [idea] Directory Depth In reply to
Thats got it! Thanks Ivan... its busy working away right now, updating the tableWink

I guess I could just run this every now and then, and it would update all the counts, for moved and/or new directories?

Edit: Yes, I see what you mean about the line breaks! I will have to wait till its done now, I suppose.

Edit 2: It conked out at a depth of 12.... I will make changes and try again.

Last edited by:

sooke: May 11, 2002, 1:47 PM
Quote Reply
Re: [yogi] [idea] Directory Depth In reply to
I conked at 12, because that was the end! Excellent job Ivan.

Edit: What an excellent thing this is..... I can now see (with a bit of sql) a breakdown of how deep my categories are:

Directory Depth /No. Of Categories

12 /26

11 /500

10 /9000

... /...

1 /16

Last edited by:

sooke: May 11, 2002, 2:10 PM
Quote Reply
Re: [sooke] [idea] Directory Depth In reply to
With this Directory Depth you can now do many other tasks in links like:
  • Remove all directories which have 0 links AND have a depth of 10 or Greater!
  • Advertising for a category banner = (Unit Price / Directory Depth) * Banner Weighting - I use this on another site of mine
  • Editor Responsiblity = A function of Category Complexity (only the cats the editor is responsible for) and Editor Status ( I have different rankings).
  • Category Complexity = (No. Subcategories * (No. Links in Category + No Link in Subcats)/2)/(Directory Depth + 1) this is what I use, but needs a little tweaking.


I personally think is a very useful and necessary variable when running a directory of any size, and should be included in Links... just my opinion.

If anyone else wishes to adopt these types of formula let me know.... perhaps we can share ideas on automating these tasks more!

Cool