Gossamer Forum
Home : Products : Links 2.0 : Customization :

Link Text versus Category Name

Quote Reply
Link Text versus Category Name
Has anyone put together a mod whereby each catgory has another field: Link Text ?

This is the text that is used to link to the relevant category as apposed to using the category name - this way you could use an abbreviated category name but perhaps have a more descriptive link text.
?
Quote Reply
Re: [auntie_t] Link Text versus Category Name In reply to
Hi,

You would just need to add the new field to category.def and enter the value you want when you add/edit a category from admin.

You'd just put the tag into category.html. eg...if the new field was TextLink you'd put <%TextLink%> in category.html
Post deleted by auntie_t In reply to

Last edited by:

auntie_t: Sep 23, 2001, 6:57 AM
Quote Reply
Not so simple In reply to
but it seems I need to change
sub site_html_print_cat
to make this work and I don't have the programming knowledge to translate the field entry in the db to an output in this subroutine
Quote Reply
Not so simple In reply to
Any guru can correct me if i'm wrong,

But as Paul has said, open your category_def, and add a new field called Link_Text.

Update your category database, and then you should be able to include that field into your template. ie: <%Link_Text%>.

I've added tons to my links and cat defs, and it works perfect.

If you want the description to be long, just make the field look something like this....

Link_Text => [8, 'alpha', '40x3', 100, 0, '', '']

And when you add a new category, you can put the text you want to appear anywhere on the category template....

Hope this helps....


Shawn
Quote Reply
Re: [automatic] Not so simple In reply to
I can't use the tag in the template. The template version I'm using requires me to incorporate this field into the subroutine mentioned above. The entire category listing is printed out from this subrouting there are no relevant tags in the template. If the template simple had <category><relevant url> it would be simple but the text-link combo is created in the perl script.

I'm using this template:
http://www.gossamer-threads.com/perl/resources/jump.cgi?ID=146
with the Yahoo subcat mod.

I have NO PROBLEM creating the categary in the db, defining it and filling the relevant field. I just can't strip it out to be associated with the relevant subcat for printout through this subroutine.

This has to be done in PERL in the site_html_templates.pl script and not through the template.


Quote Reply
Re: [auntie_t] Not so simple In reply to
Hmm......

I don't understand, if you using templates, you can't add tags to the templates?? Because of a certain mod?

That doesn't seem right.

Can you give me an example page, or something? I really don't think it should be that difficult to do.


Shawn
Quote Reply
Re: [automatic] Not so simple In reply to
Showing you the template is useless because the category listing is not template based. I don't know how else I can put this so that this is clear. The category listing is determined here:


site_html_templates.pl :
########################################################################################
# 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><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="catlist" valign="top" width="50%">\n|;

foreach $subcat (sort @subcat) {
my $mod = $stats{"$subcat"}[3];
my $new_add = $stats{"$subcat"}[4];
($description) = @{$category{$subcat}}[2];
$mod = $stats{"$subcat"}[1];

# 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];

# 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><strong><a class="link" href="$url">$category_name </a></strong> <small class="numlinks">($numlinks)</small> |;
my $days_old = &days_old($mod) / $db_new_cutoff;
if ($days_old <= 0.3) { $output .= qq| $new1|; }
elsif ($days_old <= 0.6) { $output .= qq| $new2|; }
elsif ($days_old <= 1) { $output .= qq| $new3|; }
if ($mod eq "Yes") { $output .= qq~ $updated~; }
$output .= qq||;

if ($#{$subcategories{$subcat}} >= 0) {
$v = 0;
$output .= qq~<BR><font size="1" face="MS Sans Serif"><SPAN CLASS="xsmall">~;
foreach $subcatsub (sort @{$subcategories{$subcat}}) {
$suburl = "$build_root_url/" . &urlencode($subcatsub) . "/";
if ($subcatsub =~ m,.*/([^/]+)$,) {$subcategory_name = &build_clean($1);}
else {$subcategory_name = &build_clean($subcatsub);}
$output .= qq~<A HREF="$suburl">$subcategory_name</A>~ if ($v <= 3);
$output .= qq~<font color="#000000">...</font>~ if ($v eq "3");
$output .= qq~<font color="#000000">, </font>~ if ($v ne $#{$subcategories{$subcat}} && $v <= 3);
$v++;
}
$output .= qq~</SPAN></font>~;
}

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

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