Gossamer Forum
Home : Products : Links 2.0 : Customization :

mod: category link template

Quote Reply
mod: category link template
Okay I've been thinking about why the category link HTML was never template-ized and couldn't think of any reason why it couldn't work. This only took about an hour to come up with and it worked after a couple partially successful attempts. Hope it works for you guys.

Open site_html_templates.pl and go to sub_site_html_print_cat.

Find:
Code:
# Then we print out the name linked, new if it's new, and popular if its popular.
$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">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</dt>|;
$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;
Replace with:
Code:
%cat_rec = (url => $url,
numlinks => $numlinks,
category_name => $category_name,
description => $description,
new => $new
);
if (&days_old($mod) < $db_new_cutoff) {$cat_rec{'new'} = 1}
if ($cat_rec{'description'} !~ /^[\s\n]*$/) {delete: $cat_rec{'description'}}
$output .= &site_html_category_link;
Add this new subroutine:
Code:
sub site_html_category_link {
# --------------------------------------------------------
# This routine is used to display what a category link should
# look like.

return &load_template ('category_link.html', {
%cat_rec,
%globals
});
}
Now create a new template named 'category_link.html', like the following, and place it in your templates directory:
Code:
<a href="<%url%>"><%category_name%></a>
<i>(<%numlinks%>)</i>
<%if new%>
<i><sup>new</sup></i>
<%endif%>
<%if description%>
<%description%>
<%endif%>
Change Log:
9-15-00 : BUG - 'my %cat_rec;' declaration at top of subroutine. Works correctly once removed.

--Drew
Subject Author Views Date
Thread mod: category link template sponge 1982 Sep 3, 2000, 8:00 PM
Post Re: mod: category link template
marcoBR 1864 Oct 20, 2000, 8:34 PM
Thread Re: mod: category link template
Csanad 1795 Nov 22, 2000, 8:42 AM
Post Re: mod: category link template
sponge 1780 Nov 22, 2000, 9:03 PM
Post Re: mod: category link template
DogTags 1641 Feb 8, 2001, 7:43 AM