Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: Re: [yogi] Directory Depth Global: Edit Log

Here is the list of edits for this post
Re: [yogi] Directory Depth Global
Ok, I am attempting my first perl subs here. This one is meant to be called by the add and move hooks for determining the actual category depth.

Would someone mind looking at this for possible errors (as I am not sure how to test until full routines are completed).

Code:


sub {

#Determine the directory depth for the current category &find_depth($category_id);



my $category_id = shift;

my $level = 0;



my $FatherID = $DB->table('Category')->select( 'FatherID',{ 'ID' => $category_id})->fetchrow_array;

# Loop until father = 0, incrementing level each time, thus determining depth of category

until ( $FatherID == 0) {



my $FatherID = $DB->table('Category')->select( 'FatherID',{ 'ID' => $category_id})->fetchrow_array;

$category_id = $FatherID; #just edited this

$level++;


}

return $level;

}

Last edited by:

sooke: May 14, 2002, 1:39 PM

Edit Log: