Although I'm pretty sure this has been done before, I figured I would post my code in case someone needs it...
sub {
my $in = shift;
my $category = $in->{related};
my ($rec, $related);
my $cat = $DB->table('Category');
while ($category =~ m#<li><a href="([^"]+)">([^<]+)</a></li>#sog) {
$rec->{URL} = $1;
$rec->{Category} = $2;
$rec->{Number_of_Links} = $cat->select ( { Full_Name => $rec->{Category} }, ['Number_of_Links'] )->fetchrow();
$rec->{Category} =~ s,/, > ,g;
$related .= Links::SiteHTML::display('related_category', $rec);
}
return $related;
}
This allows you to put your related categories in a template using:
<%URL%>, <%Category%>, and <%Number_of_Links%>
related_category.html is your template...
Note: You obviously also have to call your global in your category.html template with whatever name your please Ex. <%new_related%>
Hope this helps someone...
- Jonathan
Code:
sub {
my $in = shift;
my $category = $in->{related};
my ($rec, $related);
my $cat = $DB->table('Category');
while ($category =~ m#<li><a href="([^"]+)">([^<]+)</a></li>#sog) {
$rec->{URL} = $1;
$rec->{Category} = $2;
$rec->{Number_of_Links} = $cat->select ( { Full_Name => $rec->{Category} }, ['Number_of_Links'] )->fetchrow();
$rec->{Category} =~ s,/, > ,g;
$related .= Links::SiteHTML::display('related_category', $rec);
}
return $related;
}
This allows you to put your related categories in a template using:
<%URL%>, <%Category%>, and <%Number_of_Links%>
related_category.html is your template...
Note: You obviously also have to call your global in your category.html template with whatever name your please Ex. <%new_related%>
Hope this helps someone...
- Jonathan