Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

how to stop output of numlinks?

Quote Reply
how to stop output of numlinks?
I would like to NOT output the number of links in each catagory using links SQL - how does one do this?

Quote Reply
Re: how to stop output of numlinks? In reply to
Hi Squak,

I've done this easily,

Open up the file html_templates.pm in your favourite text editor.

under the sub site_html_print_cat heading which is near the bottom you will find the $numlinks variable. If you remove this it wont print the number of links in a category. MAKE SURE YOU REMOVE IT FROM ONLY THE HTML CODE!!!

It's advisabe to save your file in a different folder when ,odifying so you always have an original, so maybe save this in one called, numlinks.



Regards

MDJ1
http://www.isee-multimedia.co.uk
mark@isee-multimedia.co.uk
Quote Reply
Re: how to stop output of numlinks? In reply to
Thanks - that is how I did it in links 2.0 but in SQL I don't seem to have any HTML output that I can identify? Oh how I hate CSS -(

Here is what I have:


sub site_html_print_cat {
# --------------------------------------------------------
# This routine determines how the list of categories will look.
# We now use a table to split the category name up into two columns.
# For each category you can use the following variables:
#
# $url : The URL to go to that category
# $category_name : The category name with _ and / removed.
# $category_descriptions{$subcat}: The category description (if any).
# $numlinks : The number of links inside that category (and subcategories).
# $mod : The newest link inside of that category.
#
my ($subcat, $dynamic) = @_;
my $template = defined $dynamic ? $dynamic->param('t') : undef;
my @names = keys %{$subcat};

my ($output, $category_name, $category_url, $i, $cat, $cat_r, @subnames);
my $breakpoint = int (($#names+1) / $LINKS{build_category_columns}) + ( (($#names+1) % $LINKS{build_category_columns}) ? 1 : 0);

# Print Header.
$output = qq|<div class="margin"><table width="80%" border="0" cellspacing="0" cellpadding="0"><tr><td class="catlist" valign="top">\n|;
$i = 0;
foreach $cat (sort @names) {
$cat_r = $subcat->{$cat};

# Get the URL and the Category name.
$category_url = $LINKS{build_root_url} . "/" . &build_clean_name ($cat_r->{Name}) . "/";
($cat_r->{Name} =~ m,.*/([^/]+)$,) ? ($category_name = $1) : ($category_name = $cat_r->{Name});
$cat_r->{Short_Name} = $category_name;
$cat_r->{URL} = $category_url;


# If you are using the three level new, calculate the number of days old.
if ($LINKS{build_days_old}) {
if ($cat_r->{'Has_New_Links'}) {
$cat_r->{'Days_Old'} = &Links::DBSQL::date_diff (&Links::DBSQL::get_date(), $cat_r->{'Newest_Link'});
}
else { $cat_r->{'Days_Old'} = ''; }
}

# ------------------------------------------------
# modification starts

my ($CATDB, $subcat_info, $subcategory_r, $tmp, $subcatsub, $description, $suburl, $sub_length, $subcategory_name, $v, $subcat_length, $out);
$CATDB = new Links::DBSQL "$LINKS{admin_root_path}/defs/Category.def";
$subcat_info = $CATDB->prepare ( qq!
SELECT Category.*
FROM Category, CategoryHierarchy
WHERE CategoryHierarchy.CategoryID = ? AND
CategoryHierarchy.Depth = 1 AND
CategoryHierarchy.SubCategoryID = Category.ID
!) or die "Can't prepare: $DBI::errstr";
$subcat_info->execute($cat_r->{'ID'});
$subcategory_r = undef;

$description = $cat_r->{Description};
if (($subcat_info->rows()) && ($description =~ /^SUB.*/) ) {
$tmp = $subcat_info->fetchall_arrayref();
$v = 0;
$sub_length = "";
$out .= qq|<small>|;
foreach my $cat (@{$tmp}) {
my $temp = $CATDB->array_to_hash($cat);
$subcatsub = $temp->{Name};
$suburl = $LINKS{build_root_url} . "/" . &build_clean_name($subcatsub) . "/";
if ($subcatsub =~ m,.*/([^/]+)$,) { $subcategory_name = &build_clean_name($1); }
else { $subcategory_name = &build_clean_name($subcatsub); }

$sub_length .= qq|, | if ($description =~ /1$/ && $v ne "0");
$sub_length .= qq|$subcategory_name| if ($description =~ /1$/);

if ($description =~ /1$/ && length($sub_length) > $LINKS{subcat_length}) {
$out .= qq|...|;
last;
}
else {
$out .= qq|, | if ($description =~ /1$/ && $v ne "0");
$out .= qq|
| if ($description =~ /2$/ || $v eq "0");
$out .= qq| | if ($description =~ /2$/);
$out .= qq|<a href="$suburl">$subcategory_name</a>|;
$v++;
}
}
$out .= qq|</small>|;
}
else {
$out = $description;
}
$cat_r->{Description} = $out;

# modification ends
# ------------------------------------------------

# We check to see if we are half way through, if so we stop this table cell
# and begin a new one (this lets us have category names in two columns).
($i and ($i % $breakpoint)) or ($output .= qq|</td><td class="catlist" valign="top">\n|);
$i++;
defined $dynamic and &load_user ($dynamic, $cat_r);
$output .= &load_template ('subcategory.html', { %$cat_r, %GLOBALS }, undef, $template);
}
# Don't forget to end the unordered list..
$output .= "</td></tr></table></div>\n";
return $output;
}


Quote Reply
Re: how to stop output of numlinks? In reply to
Look for the following operators qq| and |;. Since Links SQL uses templates for the category output via the subcategory.html file, there are no generic $output statements. But if you look for the above operators that I've given, you can edit the HTML codes between them.

Regards,

Regards,

AnthroRules
Quote Reply
Re: how to stop output of numlinks? In reply to
I actually tried looking for the qq| operators - but found no reference in that file for output regarding numlinks - am I looking in the right file?

Quote Reply
Re: how to stop output of numlinks? In reply to
Ah! ok - thanks Eliot - I was in the wrong file! I was in html_templates.pm file and not subcategory.html.

Got rid of those number of links now - perfect

Quote Reply
Re: how to stop output of numlinks? In reply to
You're welcome.

Regards,

Regards,

AnthroRules