Gossamer Forum
Home : Products : Links 2.0 : Customization :

main page, columns problem

Quote Reply
main page, columns problem
on my main page the categories are displaying reasonably enough however the columns seem to be less than 50/50.

looking at the html it looks like the whole table is 80% but there seems to be no other code to stop the left hand side taking up more of the table.

Any ideas how to solve this, and more importantly WHERE i should change the code to sort it.



Thanks in advance,

bs7
Quote Reply
Re: [bs7] main page, columns problem In reply to
sub site_html_print_cat in the site_html_templates.pl file.

Search for category layout for more info.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: main page, columns problem In reply to
cheers - okay - i've spent hours reading posts and the code

but before i start re-doing all the html in the sub site_html_print_cat i was just wondering if anyone had a decent mod / code hack for it.

ie. to make the categories appear in a proper table with cells rather than a mess of </dd></dl>

cheers

bs7
Quote Reply
Re: main page, columns problem In reply to
on a separate note

is there any reason why the catagories processed AFTER

"# 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). "

would be different to those before it ?



using the sub-categories mod: the first half have

"<a class="sub" href="http://www.mysite..//index.html"></a> </dd>"

okay it can't be seen via browser so doesn't matter - BUT it isn't there for the second half of the categories

Quote Reply
Re: [bs7] main page, columns problem In reply to
There are many options...!

Do you want to nest tables? Or use CSS? CSS is better, but you may not be familiar with the coding. (BTW, your width problem may relate to <div class="margin">.) To nest tables, lookie here:

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"><table width="100%" border="0" cellspacing="0" cellpadding="0">\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|</table></td><td class="catlist" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">\n|;
}
$i++;

# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<tr><td><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|</td></tr></dl>|;
}

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

Add the red stuff, remove the green. This will put each category in it's own row/cell. Of course, you can define height, width, etc for a consistant look.


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Aug 27, 2003, 10:37 PM
Quote Reply
Re: [PerlFlunkie] main page, columns problem In reply to
 
cheers for that - it didn't quite work - it ended up quashing things a little too much

but i tried to edit it in a similar way (see below) (the bits i've changed are in bold)

BUT whenever i try mine - it ends up trying to download add.cgi and build etc.

any ideas whats wrong anyone:






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|<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td width="40%">
\n|;

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

my ($subcats) = @{$category{$subcat}}[8];
my $counter= 0;
@subcats = split(/\Q$db_delim\E/, $subcats); $subcats = "";
foreach $scat (@subcats) {

if ($counter != 0){
$subcats .= qq|,|;
}
$subcats .= qq|<a class="sub" href="$build_root_url/|;
$subcats .= &urlencode($scat);
$subcats .= qq|/$build_index">|;

if ($scat =~ m,.*/([^/]+)$,) { $subcats .= &build_clean($1);}
else {
$subcats .= &build_clean($scat);
}
$subcats .= qq|</a> |;


$counter++;
}



# 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 width="40%">\n|;
}
$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> |;
$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|<dd>$subcats</dd>|;
$output .= qq|</dl>|;
}

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

1;
Quote Reply
Re: [bs7] main page, columns problem In reply to
When prompted to download, click OK to open (not save), and you should see an error message, giving you a clue to what's wrong.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] main page, columns problem In reply to
Error including libraries: syntax error at /home/shopped/public_html/cgi-bin/admin/site_html_templates.pl line 437, near ""</td><td width="20"
Compilation failed in require at add.cgi line 33.

Make sure they exist, permissions are set properly, and paths are set correctly.

--- for add.cgi and below for nph-build.cgi ---

Error including libraries: syntax error at /home/shopped/public_html/cgi-bin/admin/site_html_templates.pl line 437, near ""</td><td width="20"
Compilation failed in require at nph-build.cgi line 33.

Make sure they exist, permissions are set properly, and paths are set correctly.



--------------

thanks for your help - cause i can't figure it out - somehow that edited line screws up the whole thing
Quote Reply
Re: [bs7] main page, columns problem In reply to
This one line is bit different than the other $output .= lines, due to the use double quotes instead of a qq|. What you need to do is change the double quotes around 20% to single quotes, like so:

$output .= "</td><td width='20%'>&nbsp;</td></tr></table>\n";


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Aug 28, 2003, 5:20 PM
Quote Reply
Re: [PerlFlunkie] main page, columns problem In reply to
thanks for that - got it working nicely now - cheers
Quote Reply
Re: [bs7] main page, columns problem In reply to
ok one other problem:

i added some SSI into the last table - and got it working on the main page BUT if a category has a sub-category then it also shows up this SSI. Is there any way around this at all?

the code is:
Code:
# Don't forget to end the unordered list..
$output .= "</td><td width='20%' VALIGN=TOP> <table border='0' cellpadding='5' bordercolor='#111111' width='100%' cellspacing='5'><tr><td width='100%' height='18' style='background-color: #F2F2F4'><b><font size='2'>SSI title:</font></b><br><br><font size='1'><!--#include virtual='/ssi_page.txt' --></font></td></tr></table></td></tr></table>\n";
return $output;


is there any way i could get that to show only for the main page and not on the category (with sub-cats) page?

or is there a better way of going about the same thing?



thanks in advance

Last edited by:

bs7: Sep 2, 2003, 3:20 AM
Quote Reply
Re: [bs7] main page, columns problem In reply to
One thing you should consider doing is using the category layout template, which I think is still in the RESOURCE section or codes posted in this forum. Basically, it's a code hack that allows you to edit a template file rather than editing the Perl/HTML codes in the site_html_print_cat subroutine.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [bs7] main page, columns problem In reply to
 
Here is something Stealth posted a few years ago, which will build one index/main page, and another for all your subcats. It solved a problem for me!

1) You will need to have two sub site_html_print_cat routines in the site_html_templates.pl or site_html.pl files depending if you are using templates. Copy the sub site_html_print_cat routine and name the new sub-routine sub site_html_print_subcat.

2) Then in your sub build_category_pages routine in the nph-build.cgi file, replace the line &site_html_print_cat with &site_html_print_subcat.

3) Re-build your index/directory.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] main page, columns problem In reply to
Thanks again PerlFlunkie - spot on - exactly what i wanted.


@ Stealth - thanks - i had considered it - but only need to sort it once and then i'll hopefully not be doing any more edits to it.
Quote Reply
Re: [PerlFlunkie] main page, columns problem In reply to
Hi!
I did like you wrote but the problem is now, the description is on the same line as the category name.
How to change the code that description apprears right underneath the category name?
Thanks in advance.
Quote Reply
Re: [churik] main page, columns problem In reply to
Did you make the changes shown way up this thread, in the red and green? If so, the this is the fix (add the red):

$output .= qq|<br><span class="descript">$description </span>| if (!($description =~ /^[\s\n]*$/));


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] main page, columns problem In reply to
Wow, worked great, thanks.
One more, the categories are very close to one another. Would you be kind to post how to add a break line or something.

Ex:

Category1
Description1
Category2
Description2

I need like this :

Category1
Description1

Category2
Description2
Quote Reply
Re: [churik] main page, columns problem In reply to
Right after the code I just posted, see this line, and add the red...

$output .= qq|<br><br></td></tr>|;


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Oct 27, 2004, 8:30 PM