Gossamer Forum
Home : Products : Links 2.0 : Customization :

Breaking Related Categories into Two Columns

Quote Reply
Breaking Related Categories into Two Columns
I'm trying to break up related categories into two columns, just like subcategories are broken up in <b>site_html_templates.pl</b> under sub site_html_print_cat. Somewhere (I can't remember where) I got this code to modify sub build_category_pages in <b>nph_build.cgi</b>:

# Calculate the related entries and put in a <LI> list.
@related = split(/\Q$db_delim\E/, $related);
$half = int (($#related) / 2);
$related = "<div class=margin><table width=80% border=0 cellspacing=0 cellpadding=0><TR><TD VALIGN=TOP WIDTH=50%>";
foreach $relation (@related) {
$related .= qq|<b><a href="$build_root_url/|;
$related .= &urlencode($relation);
$related .= qq|/$build_index">|;
@onerelated = split(/\//, $relation);
$related .= &build_clean($onerelated[$#onerelated]) . "\@\n";
$related .= "</a></b><br><img src=\"http://www.evjcc.org/images/clear.gif\[/url]" vspace=1 border=0><br>";
if ($i == $half) {
$related .= qq|</td><td valign=top WIDTH=50%>\n|;
}
$i++;
}
$related .= "</TD></TR></TABLE></div>";

I keep playing with the code--it sure looks like it should work. Sigh. But it isn't consistent. If it does manage to break them into two columns (not always the case), it doesn't break them up evenly. Does anyone have an idea what I'm doing wrong? Am I missing a change I should make somewhere else?

BTW, whatever happened to Phoenix's great Add Confirmation Mod? I have been trying to run an old copy, but came on a strange glitch. Searched the forum for discussion on the mod and came up pretty empty. Can I ask questions about a mod no longer offered?

Thanks for your help (and all the great mods everyone's added here).
Quote Reply
Re: [KM] Breaking Related Categories into Two Columns In reply to
I'm really desperate. I still can't get related categories to break into two even columns. Does anyone have any suggestions about where to look for a solution? Is there a thread here that discusses this? Please, help!

Thanks,
Kathy
Quote Reply
Re: [KM] Breaking Related Categories into Two Columns In reply to
Looks like the code you're using is from this thread:
http://www.gossamer-threads.com/...cgi?post=29654#29654


That code does more than just split the categories, it also removes redundant category names (I think...). I posted some of your code below, and suggest changing the line you have to the one that is in red, see what that does.

--

$related .= "</a></b><br><img src=\"http://www.evjcc.org/images/clear.gif\[/url]" vspace=1 border=0><br>";
if ($i == $half) {
$related .= "</td><td valign=top WIDTH=50%>\n";
}
$i++;
}
$related .= "</TD></TR></TABLE></div>";


Also (to use the code you have), still in sub build_category_pages, add the red to the existing code:

local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $next, $prev, @onerelated, $onerelated);


Leonard
aka PerlFlunkie
Quote Reply
Re: [KM] Breaking Related Categories into Two Columns In reply to
Oh, sweet! This is awesome. Thank you, thank you, thank you.

BTW, it worked. Smile

Kathy
Quote Reply
Re: [KM] Breaking Related Categories into Two Columns In reply to
Great! Glad it works fer ya! Smile

Does it list the related cats differently than normal? If so, will you post a sample of the results here? Just curious about what it looks like...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Breaking Related Categories into Two Columns In reply to
I hate to admit it, but I don't know how to put a sample up here--you can see my directory at http://jewish-web.org/jewishweb. If you don't have time for that...it lists the related categories just like categories--2 columns, bulleted. Very nice. Of course, they aren't alphabetized, but you can't have everything. Actually, I have another question about Editor's Picks, but I'd better post it in a new thread. Again, thanks so much for your help. I was tearing my hair out. Actually, I'm tearing my hair out again. But that's another story for another thread. Smile
Quote Reply
Re: [KM] Breaking Related Categories into Two Columns In reply to
Your site looks great! Thanks for the link, and yes, the mod does make the categories more logical, skipping all the redundant cats above the one listed. If you don't want the @ at the end, remove the \@ from this line:

$related .= &build_clean($onerelated[$#onerelated]) . "\@\n";


Also, I suggest putting a caption in there saying 'Related Categories' similar to the 'Links' line. **edit** Looking again, I see that there is a 'Categories' caption when there are subcats, but not when there are only related subcats. **

I copied the results from one page, and I'll paste it here:

  • Libeskind. Daniel@

  • Mendelsohn. Erich@


  • For those curious about what this code does, all the redundant cats have been removed. An unmodified 'related cat' would look like this:

    Society_and_People : Famous_People_in_Judaism : Libeskind._Daniel
    Society_and_People : Famous_People_in_Judaism : Mendelsohn._Erich

    BTW, your code is very well commented. Nice! Wink


    Leonard
    aka PerlFlunkie

    Last edited by:

    PerlFlunkie: Nov 15, 2004, 11:56 PM
    Quote Reply
    Re: [PerlFlunkie] Breaking Related Categories into Two Columns In reply to
    Thanks for the compliment. It's a brand new site; so far the only comments I've gotten on it have been Error messages from Links. Nice to have a human add their two cents. Smile

    Kathy
    Quote Reply
    Re: [KM] Breaking Related Categories into Two Columns In reply to
    Help! I've been messing around with the Editor's Pick stuff and I had to redo the changes in nphbuild.cgi. I think I did them exactly the same, but now related categories aren't being broken up into columns again. Sigh. This is what I've got:


    # Calculate the related entries and put in a <LI> list.
    @related = split(/\Q$db_delim\E/, $related);
    $half = int (($#related) / 2);
    $related = "<center><table width=100% border=0 cellspacing=0 cellpadding=0><TR><TD VALIGN=TOP WIDTH=50%>";
    foreach $relation (@related) {
    $related .= qq|<b><li><a href="$build_root_url/|;
    $related .= &urlencode($relation);
    $related .= qq|/$build_index">|;
    @onerelated = split(/\//, $relation);
    $related .= &build_clean($onerelated[$#onerelated]) . "\@\n";
    $related .= "</a></b><br><img src=\"http://www.evjcc.org/images/clear.gif\[/url]" vspace=1 border=0><br>";

    if ($i == $half) {
    $related .= "</td><td valign=top WIDTH=50%>\n";
    }
    $i++;
    }
    $related .= "</TD></TR></TABLE></center>";

    Plus I added the @onerelated, $onerelated as before. Help! Why isn't it working again?

    Kathy
    Quote Reply
    Re: [KM] Breaking Related Categories into Two Columns In reply to
    Well, I don't see any errors in the code...
    Make sure you put a comma after the last item before adding the @onerelated.


    Leonard
    aka PerlFlunkie
    Quote Reply
    Re: [PerlFlunkie] Breaking Related Categories into Two Columns In reply to
    Yipee!Smile I figured it out. I think. At least, it's working now. I added $i to the variables:

    # We set up all the variables people can use in &site_html.pl.
    ($description, $related, $meta_name, $meta_keywords, $header, $footer, $i)

    I had that in there before, but didn't think I needed it with your fix. Guess I did. Man, am I glad it's working again. What a relief. Thanks for all the time you've been taking to help me out.

    Kathy
    Quote Reply
    Re: [KM] Breaking Related Categories into Two Columns In reply to
    Hmm, I had thought of that yesterday, and was going to post it, but then you said it worked, and I guessed it wasn't needed. Apparently it is, which is good to know!
    Cool


    Leonard
    aka PerlFlunkie