Gossamer Forum
Home : Products : Links 2.0 : Customization :

Category Columns

Quote Reply
Category Columns
Hey everyone,

This would be my first post here (even though i've read a million threads). I'd like to start off by saying that Links 2.0 is one of the best shareware search scripts around.

Here's the question (and I hope this hasn't all ready been brought up):

I was wondering if someone could help me with editing my site_html.pl file under sub site_html_print_cat to make it so that the multiple categories are listed on a completely new <tr>.

So in stead of it looking something like this (please ignore the dots - it was the only way to make it look like a table):

Hockey(2) . . . . . . . . . . .Soccer(4)
This is category 1 . . . . . ..This is category 2.
Here is additional text
Even more text . . . . . . . . Basketball(7)
Some more text . . . . . . . .This is another category.
Here is some more text.
.. . . . . . . . . . . . . . . . . . Pool(2)
Football(5) . . . . . . . . . . This is another category.
This is another category.. . Some additional text.

Volleyball(12)
This is another category.



I would like it to look something like this:



Hockey(2). . . . . . . . .. . .Soccer(4)
This is category 1 . . . . . . This is category 2.
Here is additional text.
Even more text.
Some more text.

Football(5) . . . . . . . . . . .Basketball(7)
This is another category. . .This is another category.
. . . . . . . . . . . . . . . . . . . Here is some more text.

Volleyball(12) . . . . . . . . .Pool(3)
This is another category. . .This is another category.
Some additional text






I just want a nice and clean look like the second one. I really hope the above makes sense and that my imaginary tables look okay when I post this.

Thanks alot for the help.

reflex Crazy
Quote Reply
Re: [reflex] Category Columns In reply to
would this work

http://mainstop.com/...mn_link_listing.html

found in Resources section


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
I don't think so... In reply to
No I'm pretty sure that mod is for somebody using templates and it is for making your link results display in 2 columns in stead of one.

What I need is my categories to be split up into more of a basic table with just <td>'s and <tr>'s.. I don't understand the <dd>'s and <dt> tags they use in the script.

Thanks for the suggestion though.

/me is signing out

reflex Crazy
Quote Reply
Re: [reflex] I don't think so... In reply to
I was under the impression that you wanted your links in 2 columns. Your links certainly appear in two columns in your original post.

Since I could not find <dd>'s and <dt> on the page for the link I sent you, I did a search for the letters dd. The only place I found the letters was in the word add. But I am getting older and my eyes are not what they used to be - could you point out to me where the <dd>'s and <dt> are in the link I sent to you?

I'll be the first to admit I am not a perl expert. And I use templates. But as I understand it, the primary difference between using templates and not using them, is whether you want to use your own editor to edit the html files or the built in editor that comes with Links to do the same thing. But I also see differences in the code.

But the mod shows only one place to make changes to a template.

The rest of the mod is in the nph-build.cgi file and it seems like it is a simple mod. And it seems like it would do what you want.

Heck, just for the fun of it, why not change category.html, make a copy of nph-build.cgi, apply the changes from the mod to nph-build.cgi, upload the two files and see if it works? If it doesn't, undo the change to category.html and reload the saved copy of nph-build.cgi. You could do the whole thing in 10-15 minutes.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [reflex] Category Columns In reply to
Simple solution to your problem: define the height of the table cell. Fer instance: < TD height="40" width="50%" > Ignore the extra spaces... This is what I did to my site, anyway.

DD & DT are part of the HTML code for creating a definition list (DL), which is how Links displays the main page.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Category Columns In reply to
On mine, all the links are in tabke one row with two columns. I think what he wants is category headings to be on same line

THIS

Hockey(2) . . . . . . . . . . .Soccer(4)


Football(5) . . . . . . . . . . Basketball(7)


Volleyball(12). . . . . . . . Pool(2)


Not this

Hockey(2) . . . . . . . . . . .Soccer(4)

. . . . . . . . .. . . . . . . . . . Basketball(7)
Football(5)
. . . . . . . . . . . . . . . . . . Pool(2)

Volleyball(12)


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Category Columns In reply to
I've chnaged so much, I don't recall the original code, but I have mine set up to build a table for each category listing, I think. Doing this, I could have a background color for the category name, and indent the data below it. Plus, by defining the TD heights, the category names appear level across from each other. Check my site and 'view source' to see. Also, I am using templates, but you should be able to do the same thing without 'em.

I am working on converting everything to XHTML and CSS, which should greatly simplify the code. Death to <FONT> tags!! Pirate

Time...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Category Columns In reply to
hmmmm....that looks very interesting....mind sharing that little bit of code?


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Category Columns In reply to
Ok, but there's a lot of alterations in there. You should be able to see what builds the tables, though; I bolded the relevant parts. From site_html_templates, under sub_site_html_print_cat:

Code:

my (@subcat) = @_;
# *************** nonenglish modification - begin *******
# my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i, $nonenglish, $columns, $subcatsub);
# ******************** nonenglish modification - end ******
##added next line LT nonenglish/yahoo mod
# my ($half) = int (($#subcat+2) / 2);
$columns = '2'; #number of columns
my ($half) = int (($#subcat+2) / $columns);
$output = qq|<table width="510" border="0" cellspacing="0" cellpadding="0">\n|;
$output .= qq|<tr><td valign="top">\n|;




##***next two lines changed LT for arbitraty order mod***
sub byfield { $category{$a}[$cat_sort_field] <=> $category{$b}[$cat_sort_field] };
foreach $subcat (sort byfield @subcat) {
($description) = @{$category{$subcat}}[2];
# ****** nonenglish modification - begin********
($nonenglish) = @{$category{$subcat}}[8];
$subcatsub = $nonenglish if ($nonenglish);
#*** nonenglish modification - end *************

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
# ********************* nonenglish modification - begin ********
# if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
if ($nonenglish eq "") {
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
}
else {
$category_name = &build_last_title_mb($nonenglish);
}
# ******************* nonenglish modification - end **********
$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];
if ($i == $half) {
$output .= qq~</td><td width="12">&nbsp;</td><td valign="top">\n~;
$i = 0;
}

# Then we print out the name linked, new if it's new, and popular if its popular.

$output .= qq|<table width="249" cellpadding="0" cellspacing="0"><tr><td width="4" height="20" bgcolor="#eeeeee" valign="top">&nbsp;</td><td width="245" height="20" bgcolor="#eeeeee" valign="middle">\n|;

$output .= qq|<font face="Verdana, Helvetica, Arial" size=2><b><a href="$url">$category_name</a></b>
<small>($numlinks)</small> |;

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


### next added LT 2002-Yahoo###
### added 'byfield' for arbitrary order mod###
if ($#{$subcategories{$subcat}} >= 0) {
$v = 0;

$output .= qq~<tr><td width="8" height="68" valign="top">&nbsp;</td><td width="247" valign="top"><font face="verdana, helvetica, arial" size="2">~;

foreach $subcatsub (sort byfield @{$subcategories{$subcat}}) {
($nonenglish) = @{$category{$subcatsub}}[8];
$subcatsub2 = $subcatsub;
$subcatsub2 = $nonenglish if ($nonenglish);
$suburl = "$build_root_url/" . &urlencode($subcatsub) . "/";
if ($subcatsub2 =~ m,.*/([^/]+)$,) { $subcategory_name = &build_last_title_mb($1); }
else { $subcategory_name = &build_last_title_mb($subcatsub2); }

$output .= qq~<A HREF="$suburl">$subcategory_name</A>~ if ($v <= 5);
$output .= qq~<font color="#000000">,&nbsp; ~ if ($v ne $#{$subcategories{$subcat}} && $v <= 5);
$output .= qq~<font size="1"><A HREF="$url"> more</A><font color="000000">...</font>~ if ($v eq "5");

$v++;
}
$output .= qq~</font></td></tr></table>~;
}
###end added LT###
#LT $output .= qq|<dd><span class="descript">$description
#</span></dd>| if (!($description =~ /^[\s\n]*$/));
# $output .= qq|</dl></font></td>\n|;
$i++;
}
$output .= "</td></tr>\n</table>\n";
return $output;
}

Good luck! Maybe when I convert to XHTML/CSS, I'll clean up the code some...?
Chop, chop!!


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Category Columns In reply to
Here is the close to orginial code:

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

# Print Header.
$output = qq~<table width="500" border="0" cellspacing="0" cellpadding="0"><tr><td class="main" valign="top" width="250">\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="main" valign="top" width="250">\n~;
}
$i++;


# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq~<dl><dt><b><a class="main" href="$url">$category_name</a></b> <small>($numlinks)</small> ~;
$output .= qq~<sup>new</sup>~ if (&days_old($mod) < $db_new_cutoff);
$output .= qq~</dt>~;
$output .= qq~<br>$description~ if (!($description =~ /^[\s\n]*$/));
$output .= qq~</dl>~;

}



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




The bolded text is the table. I tried changing the height but that did not work. I think it is because of the <dl> and <dt>. If I could just edit it to use just <td> and <tr> then maybe I could define the height.

Any ideas?

relfex Crazy
Quote Reply
Re: [reflex] Category Columns In reply to
My code above builds the main table, but then puts each category into a nested table, and stacks them up in two columns. It was a quick-fix, but having that many tables is not a good thing. When I first created all this stuff a few years ago, I was ignorant of CSS, but now see it as the savior of the web!

Try this, which will use CSS:

Code:
# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq~<span class="cathome"><b><a class="main" href="$url">$category_name</a></b><small>($numlinks)</small>~;
$output .= qq~<sup>new</sup>~ if (&days_old($mod) < $db_new_cutoff);
$output .= qq~</span>~;
$output .= qq~<br><span class="deschome">$description~ if (!($description =~ /^[\s\n]*$/));
$output .= qq~</span>~;
##edit=moved the first closing SPAN tag to it's own line.

Then add these to the stylesheet (.CSS):

Code:


.cathome {
background-color: #eeeeee
}

.deschome {
height: 40px;
text-indent: 10px;
margin-bottom: 6px;
margin-right: 4px;
}
I think that'll do it. You can adjust the color and various widths. I have not worked with adding CSS to Perl yet, so it may need some tweaking. Let me know...


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Nov 4, 2002, 12:53 PM
Quote Reply
Re: [PerlFlunkie] Category Columns In reply to
Your solution has seemed affective.

I thank you for all your help.

Best wishes, reflex Crazy

Last edited by:

reflex: Nov 4, 2002, 2:19 PM