Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Category contents display...How Do I ?

Quote Reply
Category contents display...How Do I ?
How do i display the contents of a category within a HTML(like SSI output). If I use <%category%> it prints whole category list in the top level. Instead i need to display the category contents of only one sub-category in a HTML, with appropriate links for the displayed contents.

Thanks,

Venkat
Quote Reply
Re: [vensub71] Category contents display...How Do I ? In reply to
You'll need to use a global.

If you go to admin>build and click on Template Globals you can add a global. If you want a list of all the links in the category you could try this:

sub {
my $tags = shift;
my $cat_id = $tags->{'ID'};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY Title ASC");
my $sth = $link_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' });
my $output;
while (my $link = $sth->fetchrow_hashref) {
$output .= qq~ <li><a href="$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}">$link->{'Title'}</a> ~;
}
return $output;
}

If you call it linkslist, then in your category template you can call it with <%linkslist%>

Laura.
The UK High Street
Quote Reply
Re: [afinlr] Category contents display...How Do I ? In reply to
Thanks Laure. But I need to print the subcat list (instead of link list) output of a particular category in a HTML file (like SSI ) how do i do?

For example you have a total of 120000 category. Each category has at least one sub-category named 'Restaurant' . I would like to print the contents of a specific 'Restaurant' category with its subdirectory names(with links) in a HTML somewhere else.

I may want to pull the contents of that and print under a heading called "Restaurants in Boston area" .

<%category%> will print all. But if it is a specific category. Something like passing a parameter for "<%category%>?Cities/Boston/Restaurants"

Thanks,
Vensub