Gossamer Forum
Quote Reply
Help With Global
This Global objective is to determine how many links in each category have the custom column LinkType set to the value: Detailed.



Code:
sub { my $LinkType = "Products";
my $type = "Detailed";
my ($last,@dirs,$output,@cat_list,$linea,@ordena_cat,$howmany); my $home = 1;
my $complete = 0; # Purpose?


my ($katid, $tags) = @_;

my $cat_db = $DB->table('Category');
my $links_db = $DB->table('Links');
my $relation = $DB->table('CatLinks', 'Links');
my $relation2 = $DB->table('Category', 'Links');


my @root_cats = $cat_db->select (['Full_Name'], { FatherID => $tags })->fetchall_list;
my @id_cats = $cat_db->select (['ID'], { FatherID => $tags })->fetchall_list;


my $counter;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
@dirs = split (/\//, $root_cat);
$last = pop @dirs unless ($complete);

my $sth = $relation->select( { CategoryID => $id_cats[$counter] } );
my ($count) = $sth->fetchrow_array;


my $sth2 = $relation2->select( { 'Category.ID' => $id_cats[$counter] , LinkType => $type } );
my ($count2) = $sth2->fetchrow_array;


my $count3 = $cat_db->select({ ID => $id_cats[$counter] })->fetchrow_hashref;


#### $count3, $count2 and $count are tests

my $total_links = "$count3->{Number_of_Links} - $count2 - $count";
$cat_list[$counter] = "<li><a class='$last' href='$CFG->{build_root_url}/$LinkType/$url'>$last</a> $total_links<br>";
$counter++;
}


@ordena_cat = sort {uc($a) cmp uc($b)} @cat_list;

foreach $linea (@ordena_cat) {
$output .= qq~$linea~;
}
return $output;
}
Subject Author Views Date
Thread Help With Global jaltuve 2328 Mar 25, 2003, 6:36 PM
Thread Re: [jaltuve] Help With Global
jaltuve 2234 Mar 25, 2003, 6:39 PM
Thread Re: [jaltuve] Help With Global
Paul 2218 Mar 26, 2003, 1:02 AM
Post Re: [Paul] Help With Global
jaltuve 2197 Mar 26, 2003, 1:22 PM