Gossamer Forum
Home : Products : Gossamer Links : Discussions :

building 1 column category ?

Quote Reply
building 1 column category ?
I want to modify the file sitehtml.pm by hand and build a 1 column category

how would I modify this section to build 1 column ?

I tried changing build_category_columns to 1 but got error messages

sub site_html_print_cat {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{build_category_columns}) + ( (($#{$subcat}+1) % $CFG->{build_category_columns}) ? 1 : 0);
my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
my $output = '';
my $i = 0;
my $cat_db = $DB->table('Category');
my $opts = { dynamic => 0 };
Quote Reply
Re: [incik] building 1 column category ? In reply to
Why not just set it to 1 through the admin panel?
Quote Reply
Re: [RedRum] building 1 column category ? In reply to
 The reason is because I made a second sub site_html_print_cat and renamed it sub site_html_print_cat_home this way when it builds it only builds for the home.html and not the entire site.

Thats why I want to build a single column category for my home.html outside the entire site.
Quote Reply
Re: [incik] building 1 column category ? In reply to
What were the error messages?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] building 1 column category ? In reply to
This is how it looks:

sub site_html_print_cat_home {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{1}) + ( (($#{$subcat}+1) % $CFG->{1}) ? 1 : 0);
my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
my $output = '';
my $i = 0;
my $cat_db = $DB->table('Category');
my $opts = { dynamic => 0 };



Hers the error mesage:

A fatal error has occured:
Illegal division by zero at SiteHTML.pm line 226.

Please enable debugging in setup for more details.




Quote Reply
Re: [incik] building 1 column category ? In reply to
Thanks

I figured it out a different way

Quote Reply
Re: [incik] building 1 column category ? In reply to
The error was due to something being divided by 0 in the code.

It must have been:

my $breakpoint = int (($#{$subcat}+1) / $CFG->{1}) + ( (($#{$subcat}+1) % $CFG->{1}) ? 1 : 0);

-OR-

my $width = int (100 / $CFG->{build_category_columns});

You need to use eval to bypass that error.
Quote Reply
Re: [RedRum] building 1 column category ? In reply to
It was $CFG->{1}, it's trying to look something up in the config with a key of 1. This doesn't exist and returns undefined, which turns it into a divide by zero. Replace $CFG->{1} with 1 and it should be fine.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] building 1 column category ? In reply to
I went further down and modified this line:

(0 > 0) and !(1 % $breakpoint) and ($output .= qq|</td>\n<td valign="top" width="$width%" class="catlist">\n|);

before it looked like this:

($i > 0) and !($i % $breakpoint) and ($output .= qq|</td>\n<td valign="top" width="$width%" class="catlist">\n|);

and it made the single column category like I wanted.

Thanks guys