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

Category Build

Quote Reply
Category Build
Which file has the table that is used to display the categories. When you select 2 colums I want to be able to give each colum a width of 50% as this would make it more centered.

# Number of columns to display a list of categories.
$LINKS{build_category_columns} = 2;

Any help would be great.

Jason
Quote Reply
Re: Category Build In reply to
Thanks pugdog perfect.

http://www.weblinks.com.au/d/index.html

Jason
Quote Reply
Re: Category Build In reply to
In HTML_Templates.pm you'd want to make it look something like:

Code:
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|<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top" width=33%>\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, uncomment the following to have Days_Old available in the
# template.
if ($cat_r->{'Has_New_Links'}) {
$cat_r->{'Days_Old'} = &Links: BSQL::date_diff (&Links: BSQL::get_date, $cat_r->{'Newest_Link'});
}

# 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>0) && !($i % $breakpoint)) && do {$output .= qq|</td>\n<td valign="top" width=50%>\n|;};
$i++;
defined $dynamic and &load_user ($dynamic, $cat_r);
$output .= &load_template ('subcategory.html', {%$cat_r, %GLOBALS} , undef, $template); ##_## had to pass the %GLOBALS and %$cat_r as a hash to the routine
}
# Don't forget to end the unordered list..
$output .= "</td></tr></table>\n";
return $output;
}

and your subcategory.html would look something like:

Code:
<TABLE BGCOLOR=WHITE WIDTH="100%" BORDER="0" CELLSPACING=0 CELLPADDING=2>
<tr>
<td COLSPAN=2 WIDTH=100% BGCOLOR="WHITE" valign="MIDDLE">
<FONT FACE=ARIAL SIZE=2><B><a href="<%URL%>"><%Short_Name%></a></B><FONT SIZE=1><B> (<%Number_of_Links%>: Links)</B></FONT>
<%if Has_New_Links eq 'Yes'%>
<%if Days_Old < 15%>
<img src=<%build_root_url%>/../images/new_<%Days_Old%>.gif>
<%endif%>
<%endif%>
<%if Has_Changed_Links eq 'Yes'%><FONT FACE=ARIAL COLOR=RED><sup>update</sup></FONT><%endif%>
</FONT>
</td>
</tr>
</TABLE>
<%if Description%>
<TABLE WIDTH="100%" CELLPADDING=2 CELLSPACING=0>
<TR>
<TD VALIGN=MIDDLE WIDTH="5%" BGCOLOR="WHITE">
<FONT COLOR=WHITE>.</FONT>
</TD>
<TD VALIGN=MIDDLE WIDTH="95%" BGCOLOR="#EEEEEE">
<FONT FACE=ARIAL SIZE=2>
<%Description%>
</FONT>
</TD>
</TR>
</TABLE>
<%endif%>

In other words, your subcategory.html has to be a self contained unit.

It's much easier to edit that way, than to have to work with things inside TR tags.

This will make a front page similar to http://www.girlfriends.com