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

yahoo subcats mod for list

Quote Reply
yahoo subcats mod for list
For those who got used to the list formatting for the yahoo sub cats (which I'm partial to) here is the modified routine for the YahooSubcats.pm file

Code:

my $cats = shift;
my $category = $DB->table('Category');
my $cfg = Links::Plugins::get_plugin_user_cfg('YahooSubcats');
for my $cat (@$cats) {
if ($cat->{Description} =~ /SUB[01]/) {
$category->select_options("ORDER BY $cfg->{subcat_order}") if $cfg->{subcat_order};
my $sth = $category->select('Full_Name', 'Name', { FatherID => $cat->{ID} });
my ($description, $len, $numcats);
if ($cfg->{limit_by} eq 'N' and ($cat->{Description} =~ /SUB[0]/) ) { $description .= '  '};
while (my $subcat = $sth->fetchrow_hashref) {
$len += length $subcat->{Name};
$numcats++;
if ((($cfg->{limit_by} eq 'L' and $len > $cfg->{subcat_length}) or
($cfg->{limit_by} eq 'N' and $numcats > $cfg->{num_subcats})) and
$cat->{Description} =~ /SUB1/) {
$description .= ' ...';
last;
}
if ($cfg->{limit_by} eq 'N') {
$description .= ",<br>\n\&nbsp;\&nbsp;" unless $numcats == 1;
} else {
$description .= ', ' unless $numcats == 1;
}
$description .= qq|<a href="$CFG->{build_root_url}/| . $category->as_url($subcat->{Full_Name}) . qq|/$CFG->{build_index}">$subcat->{Name}</a>|;
}
$cat->{Description} =~ s/SUB[01]/$description/;
}
}
}


If you use SUB0 to list all your categories in a vertical list, you can use the L or N parameter to swtich between listing them all in a lump (L) or in a list with \n formatting (N). (It's really a <br>\n , but the mnemonic works).

It's a "hack" since you can't really swtich between SUB0/1 (unless you use the "N" format for SUB1) but it does mean the install doesn't have to be edited.

I'll probably have a further modified version out soon, with the extra options settable from the admin panel, including the ability to change the indent, or use bullets, but for now, this does the trick for me ... I only use SUB0, with a 2 space indent on most sites.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] yahoo subcats mod for list In reply to
Hi, maybe you should consider using <br /> instead of <br> Cool