I think the answer to this one lays in the Directory Dept function that Ivan just wrote, especially this part:
Code:
# Immediate subcats
my @category_level;
my $sth = $l_cat->select ({FatherID => 0});
while (my $category = $sth->fetchrow_hashref) {
push @category_level, $category;
&update_cat($category,$level);
}
@categories[$level] = \@category_level;
$level++;
# Fetch all subcategories below
while ($#{$categories[$level-1]} > 0) {
my @category_level;
my $num_cat_father_level = $#{$categories[$level-1]} + 1;
for (my $i=0; $i < $num_cat_father_level; $i++) {
my $father_id = ${$categories[$level-1]}[$i]->{ID};
my $sth = $l_cat->select ({FatherID => $father_id});
while (my $category = $sth->fetchrow_hashref) {
push @category_level, $category;
&update_cat($category,$level);
}
}
@categories[$level] = \@category_level;
$level++;
}
return;
}
Except:
Don't increment the directory depth, rather just count the number of sub directories.
It would have to loop through this for each entry an editor has in the records table, but minus out duplicated categories. Still awful complicated, but I think this is one step closer.
Food for thought!