Gossamer Forum
Home : Products : Links 2.0 : Customization :

To many columns being displayed

Quote Reply
To many columns being displayed
I have made the changes to site_html_templates to get 3 columns. I followed the instructions given in the Gossamer Threads faq section. However there is one problem that keeps re occurring. When there is an odd number of categories, lets say 7, the script displays 4 columns instead of 3. As for that matter anything not divisible by 3 and greater than 3 would create a 4th column. Does anyone know how to force the script to stick with 3 columns?
--
Tobias

Quote Reply
Re: To many columns being displayed In reply to
So does anyone know the answer to this problem? I hope its not to hard.
--
Tobias

Quote Reply
Re: To many columns being displayed In reply to
I use Junko's code and have no problems with it at all. Is that what you are using?

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: To many columns being displayed In reply to
Well what I have changed in site_html_template to is this:

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) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);
my ($half) = int (($#subcat+2) / 3);


# Print Header.
$output = qq|<div class="margin"><table width="80%" border="0" cellspacing="0" cellpadding="0"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];

# 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).
if ($i == $half) {
$output .= qq~</td><td class="catlist" valign="top">\n~;
$i = 0;
}
$i++;

# 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> |;
my $days_old = &days_old($mod); if ($days_old <= 2) { $output .= qq| $new_1|; } elsif ($days_old <= 7) { $output .= qq| $new_3|; } elsif ($days_old <= 14) { $output .= qq| $new_7|; }
$output .= qq|</dt>|;
$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;
}

# Don't forget to end the unordered list..
$output .= "</td></tr></table></div>\n";
return $output;

------------
For reference you can check out my website at: www.chatinternational.com/links/
You will see that where there are an odd number of categories there is an extra column.

--
Tobias

Quote Reply
Re: To many columns being displayed In reply to
Yes, but is that Junkos code? Did you get it from http://www.camelsoup.com/?view=columns ???? It doesn't look like it is. If not, then just scrap that and use Junkos code at the above URL (you will need to replace the subs you have messed around with the origial subs). That should work.

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: To many columns being displayed In reply to
Ok, I have replaced the old code with junkos code, plus I made some modifications so that 2 columns are displayed in home page while 3 are displayed in category page. However if you check out the category Asia http://www.chatinternational.com/links/Asia/ you will find that it has 4 columns instead of 3. The Europe category http://www.chatinternational.com/links/Europe/ on the other hand has 3 categories. Asia has 16 subcategories while Europe has 30 subcategories.
--------
Tobias

Quote Reply
Re: To many columns being displayed In reply to
Well I have changed the site_html_templates.pl to Junkos mod but it still doesn't work properly. I would challenge anyone who is using 3 columns in categories to see if they get 4 columns if they have a number of categories that is not divisible by 3 (7 or 16,etc). When I have this many categories or subcategories I get 4 columns instead of 3. Does any of you experts out there know what could be causing this and how to fix it.
---
Tobias

Quote Reply
Re: To many columns being displayed In reply to
tobbe1.. go back to the original copy of your site_html.pl (non-templates) or site_html_templates.pl (if you are using templates). THEN try the following changes again. This works b/c I've gotten this to work (and if I got it working.. heh... anyone can get it to work).

Find:

my ($half) = int (($#subcat+2) / 2);

Replace with:

$columns = '3'; #number of columns
my ($half) = int (($#subcat+2) / $columns);


Find:

if ($i == $half) {
$output .= qq~</td><td class="catlist" valign="top">\n~;
}


Replace with:

if ($i == $half) {
$output .= qq~</td><td class="catlist" valign="top">\n~;
$i = 0;
}

Thats all.. now just adjust the $columns = x, x being the number of columns you want. Currently its setup to 3... so that above code should work perfectly. Try that, whoever made that little mod is a genious... and credit goes to that guy ofcourse...

good luck...

--------------------------------------------
:oD :o) :ob :op :oO =oD =o) =ob =op =oO
Quote Reply
Re: To many columns being displayed In reply to
That is the mod we were already talking about - Junko's mod.

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: To many columns being displayed In reply to
yeah.. sorry for interrupting oops...
I wanted to emphasize on the possibility that it might workout using a fresh (unmodified) site_html_template.pl file.. as it doesn't look like that he's done alot of mods on his current one. So re-editing a fresh one might just work out.. sorry for interruptinga again

--------------------------------------------
:oD :o) :ob :op :oO =oD =o) =ob =op =oO
Quote Reply
Re: To many columns being displayed In reply to
I wasn't meaning you shouldn't have interrupted. There is no problem with you posting - no-one owns the thread. I was just pointing out that he had already tried Junko's mod and it didn't seem to be working for him (although it does for me).

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: To many columns being displayed In reply to
I want to make my catetgories 3 instead of two. It is ugly and looks horrible. How this is my site_html_templates.pl file. Now when I tried to change it, it shows all the categories listed instead of broken into 3

########################################################################################
# THE FOLLOWING DETERMINES YOUR CATEGORY LISTING, IT'S NOT TEMPLATE BASED (YET)! #
########################################################################################

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) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);
my ($half) = int (($#subcat+2) / 2);

# Print Header.
$output = qq|<div class="margin"><table width="80%" border="0" cellspacing="0" cellpadding="0"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];

# 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).
if ($i == $half) {
$output .= qq|</td><td class="catlist" valign="top">\n|;
}
$i++;

# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<dl><dt><FONT SIZE="2" FACE="Verdana, Arial" COLOR="000000"><a href="$url">$category_name</a> ($numlinks) |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</dt>|;
$output .= qq|<dd>$description </dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;
}

# Don't forget to end the unordered list..
$output .= "</td></tr></table></div>\n";
return $output;
}

1;

Quote Reply
Re: To many columns being displayed In reply to
You didn't install the mod properly.

Read the posts in this thread.

Installations:http://www.wiredon.net/gt/

Quote Reply
Re: To many columns being displayed In reply to
Okay I have it installed but look at how the category font looks. I dont want it that big, how am I going to shrink this?
http://search.rootssearch.net

Quote Reply
Re: To many columns being displayed In reply to
Look for the lines beginning with

$output .=

...they contain the html.

Installations:http://www.wiredon.net/gt/

Quote Reply
Re: To many columns being displayed In reply to
THANK YOU!!!!!!! :)

It's looking great now! Check it out http://search.rootssearch.net