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

Help in hacking YahooSubcats

Quote Reply
Help in hacking YahooSubcats
I have been successful in installing a hack called "YahooSubcatsFR". I was thinking I needed a new version of the plug in for a second language. I wanted to use SUB2 & SUB3 in the new language. SUB2 would do the same as SUB0. SUB3 would show the other languages title for the subcats. If this is only about renaming variables, could some one point this out to me?. I am close to getting what I want. But I have no knowledge of Perl. So I am stuck.

sub create_subcats {
# ------------------------------------------------------------------
# Sets the description for Yahoo Style Subcategories.
#
my $subcat = shift;
my $cat_db = $DB->table('Category');
my $cfg = Links::Plugins::get_plugin_user_cfg ('YahooSubcats');
for (my $x=0;$x<scalar(@$subcat);$x++) {
my $cat_r=$subcat->[$x];
if ($cat_r->{Description} =~ /SUB0/ || $cat_r->{Description}=~/SUB1/) {
my $catid=$cat_r->{ID};
my $table = $DB->table('Category');
my $sth=$table->select({'FatherID' => $catid},['Full_Name','Name']);
my $description="";
my $len=0;
my $numcats=1;
while (my $row=$sth->fetchrow_hashref()) {
my $cat_url = $CFG->{build_root_url} . "/" . $cat_db->as_url ($row->{Full_Name}) . "/" . $CFG->{build_index};
if (($cfg->{limit_by} eq 'L') and (($len + length($row->{Name})) > $cfg->{subcat_length})) {
if ($cat_r->{Description}=~/SUB1/){
$description.='...';
last;
}
else {
$description.=",<br>";
$len=0;
$numcats=0;
}
}
elsif (($cfg->{limit_by} eq 'N') and (($numcats) > $cfg->{num_subcats})) {
if ($cat_r->{Description}=~/SUB1/){
$description.='...';
last;
}
else {
$description.=",<br>";
$numcats=1;
$len=0;
}
}
$len!=0 and $description.=',';
$len+=length($row->{Name});
$numcats++;
$description.=qq|<a href="$cat_url"><$cfg->{subcat_font}>$row->{Name}</font></a>|;
}
if ($cat_r->{Description}=~/.SUB[01]/s) {
$description="<br>".$description;
}
if ($cat_r->{Description}=~/SUB[01]./s) {
$description.="<br>";
}
$cat_r->{Description}=~s/SUB[01]/$description/;
$subcat->[$x]=$cat_r;
if ($subcat->[$x]->{Description}=~/SUB[01]/){$subcat->[$x]->{Description}=~s/SUB[01]//;}
}
}
return $subcat;
}

sub about {
print $IN->header();
print Links::header ('YahooSubcats Help Menu', qq|
<p>This plugin allows you to automatically generate Yahoo Syle subcategories. For instance, if you have
a category Computers, with subcategories Hardware, Software and Companies, using this mod, your main listings
will automatically look like:

<blockquote>Computers<br><font size=-1 color="blue"><u>Hardware</u>, <u>Software</u>, <u>Companies</u></font>
</blockquote>

<p>To do this, simply place either the word SUB0 or SUB1 as the <i>Description</i> for the category you want.

<p>If you specify SUB0, all subcategories will be listed. If you specify SUB1 the first few subcategories
will be listed up to subcat_length characters.
| );
}

# Always end with a 1.
1;
Subject Author Views Date
Post Help in hacking YahooSubcats nt6 1737 Nov 16, 2002, 8:40 AM