This is in reference to http://www.gossamer-threads.com/...orum.cgi?post=195612, but since this about a global I am posting here.
I just wrote my first global!!!
This one prints out the number of categories with a directory depth of X.
sub {
#print number of categories by directory depth - depth stats
my $max_depth;
my $num_cats;
my $count;
my ($max_depth) = $DB->table('Category')->select(['MAX(Depth)'])->fetchrow_array;
for ($count=0; $count<=$max_depth; $count++)
{
my ($num_cats) = $DB->table('Category')->select(['COUNT(Depth)'],{ 'Depth' => $count})->fetchrow_array;
print "Directory Depth: $count Number of Categories: $num_cats<br>";
}
}
The next step (which is way beyond me still) is to turn this and the perl module from the thread mentioned at the top of this page into a plugin which:
Most of this is already done, just how do I make this into a plug in?
Any help would be great, maybe I can move onto understand plugins a little more now!
I just wrote my first global!!!

This one prints out the number of categories with a directory depth of X.
Code:
sub {
#print number of categories by directory depth - depth stats
my $max_depth;
my $num_cats;
my $count;
my ($max_depth) = $DB->table('Category')->select(['MAX(Depth)'])->fetchrow_array;
for ($count=0; $count<=$max_depth; $count++)
{
my ($num_cats) = $DB->table('Category')->select(['COUNT(Depth)'],{ 'Depth' => $count})->fetchrow_array;
print "Directory Depth: $count Number of Categories: $num_cats<br>";
}
}
The next step (which is way beyond me still) is to turn this and the perl module from the thread mentioned at the top of this page into a plugin which:
- Assigns a category its directory depth when it is added or moved.
- Creates a stats display under the Globals menu in admin which shows what my Global does
- Has a function which does recalculates all directory depths, exactly as the above mentioned perl module does - for repair purposes, or after an import.
Most of this is already done, just how do I make this into a plug in?
Any help would be great, maybe I can move onto understand plugins a little more now!
