Gossamer Forum
Home : Products : Links 2.0 : Customization :

Link counts in subcats ...

Quote Reply
Link counts in subcats ...
Hi,
again an often asked question ... I've searched the forum, but didn't find a solution...

I'm using the german version of links2 with a subcat mod, ton show subcats on the main page... I've treid to show the number of links in the subcat behind the subcat name: scat1(xx), scat2(xx), ....

But as I'm not very familiar with perl I didn't find a way... but it seems to me, that this must be easy ...

Here ist my

sub site_html_print_cat {
# --------------------------------------------------------

my (@subcat) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i, $nonenglish);
my ($half) = int (($#subcat+2) / 2);


$output = qq|<div class="margin"><table width="95%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];
($nonenglish) = @{$category{$subcat}}[8];
##############################
my ($subcats) = @{$category{$subcat}}[9];
##############################     
@subcats = split(/\Q$db_delim\E/, $subcats); $subcats = "";
foreach $scat (@subcats) {
$subcats .= qq|<font size="-3"><b><a href="$build_root_url/|;
$subcats .= &urlencode($scat);
$subcats .= qq|/$build_index">|;

if ($scat =~ m,.*/([^/]+)$,) { $subcats .= &build_clean($1);}

else {
$subcats .= &build_clean($scat);
}
$subcats .= qq| </a></b>(X),</font> |;
}
######################

$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($nonenglish eq "") {
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
}
else {
$category_name = &build_last_title_mb($nonenglish);
}

$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];


if ($i == $half) {
$output .= qq|</td><td width=\"10\">&nbsp;</td><td class="catlist" valign="top">\n|;
}
$i++;


$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
# $output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">neu</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|<br>|;
# $output .= qq|</dt>|;
$output .= qq|<span class="descript">$description</span>| if (!($description =~ /^[\s\n]*$/));
# $output .= qq|<dd><span class="descript">$description</span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|<span class="descript"> Mehr: $subcats</span>|;
# $output .= qq|<dd><span class="descript">$subcats</span></dd>|;
$output .= qq|<br><br>|;
# $output .= qq|</dl>|;
}


$output .= "</td></tr></table></div>\n";
return $output;
}


hope, that someone can help me...

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de

Last edited by:

kailew: Apr 28, 2003, 6:52 AM
Quote Reply
Re: [kailew] Link counts in subcats ... In reply to
Hi,

no one here, who can help me...?

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de
Quote Reply
Re: [kailew] Link counts in subcats ... In reply to
I'm not sure if this will work with the german version but check out http://www.gossamer-threads.com/...tring=number;#234923

I believe there was another discussion on this topic within the few months. try searching for $numlinks, $subcat or site_html_print_cat and select within 6 months.

maybe http://www.gossamer-threads.com/...ml_print_cat;#234337


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."

Last edited by:

esm: Apr 30, 2003, 2:13 AM
Quote Reply
Re: [esm] Link counts in subcats ... In reply to
Hi Gene,
thx, but I've searched the forum and found this one a few days ago... this might work, but is still a complete different version of subcat mod than mine. So I have to change the subcat mod, which I like to avoid...Crazy

I guess that I use a mod of glennu and I contacted him, but receive no answer so far ...

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de
Quote Reply
Re: [kailew] Link counts in subcats ... In reply to
well, if it works, do you really care what the code looks like? Sly

glennu has been on the board in over a year and a half.

give it a try and see if it will work...


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Link counts in subcats ... In reply to
Hi Gene,

this will work *only*, if I change the subcat mod first... and this isn't easy as it looks like Unsure ...

Probably I will get other problems because of using the german version and so on...

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de
Quote Reply
Re: [kailew] Link counts in subcats ... In reply to
Just a thought, may not work...



edit:>>>>Just tried it on my "test" site, and it puts the total number of links in the main cat, not broken down by sub-cats... No workie!<<<<:edit

else {
$subcats .= &build_clean($scat);
}
$subcats .= qq| </a></b><small class="numlinks">($numlinks)</small> ,</font> |;
}
######################


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Apr 30, 2003, 11:51 AM
Quote Reply
Re: [kailew] Link counts in subcats ... In reply to
Kailew,

I looked at you code, and the one referred to by esm, and saw these differences (add the blue, remove the red):

sub site_html_print_cat {
# --------------------------------------------------------


my ($subcats_id) = @{$category{$subcat}}[0];

my ($output, $sep, $hit_count, $id);
$sep = "|";
open (DB, "$db_category_name") or &cgierr ("unable to open category database: $db_category_name. Reason: $!");
LINE: while (<DB>) {
/^#/ and next LINE;
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.

my @values = &split_decode($_);

if ($values[5] == $subcats_id) { $hit_count++; }

}
close DB;

my ($subcats) = @{$category{$subcat}}[9];




my (@subcat) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i, $nonenglish);
my ($half) = int (($#subcat+2) / 2);


$output = qq|<div class="margin"><table width="95%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];
($nonenglish) = @{$category{$subcat}}[8];
##############################
my ($subcats) = @{$category{$subcat}}[9];
##############################
@subcats = split(/\Q$db_delim\E/, $subcats); $subcats = "";
foreach $scat (@subcats) {
$subcats .= qq|<font size="-3"><b><a href="$build_root_url/|;
$subcats .= &urlencode($scat);
$subcats .= qq|/$build_index">|;

if ($scat =~ m,.*/([^/]+)$,) { $subcats .= &build_clean($1);}

else {
$subcats .= &build_clean($scat);
}
$subcats .= qq| </a></b>($hit_count),</font> |;
}
######################

$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($nonenglish eq "") {
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
}
else {
$category_name = &build_last_title_mb($nonenglish);
}

$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];


if ($i == $half) {
$output .= qq|</td><td width=\"10\">&nbsp;</td><td class="catlist" valign="top">\n|;
}
$i++;


$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
# $output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">neu</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|<br>|;
# $output .= qq|</dt>|;
$output .= qq|<span class="descript">$description</span>| if (!($description =~ /^[\s\n]*$/));
# $output .= qq|<dd><span class="descript">$description</span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|<span class="descript"> Mehr: $subcats</span>|;
# $output .= qq|<dd><span class="descript">$subcats</span></dd>|;
$output .= qq|<br><br>|;
# $output .= qq|</dl>|;
}


$output .= "</td></tr></table></div>\n";
return $output;
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Link counts in subcats ... In reply to
Hi Leonard,
thx so far, I will try it tomorrow and let you know whether I was successful or not...

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de
Quote Reply
Re: [kailew] Link counts in subcats ... In reply to
Hi Leonard,

I've tried your tipps, but the only result was "50"... As count I always get "50"... strange...

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de