Gossamer Forum
Home : Products : Links 2.0 : Customization :

Graphics for Category Names

(Page 2 of 2)
> >
Quote Reply
Re: Graphics for Category Names In reply to
The problem with some of the approaches here is that they can't handle underscores or special charaters in the category names.

However, AnthroRules' approach seems like it would be good because it's simple and you don't have to worry about special characters or underscores in the category name causing problems.

The problem that I'm having with AnthroRules' suggestion is that the cat ID is not being carried over to the page output. So, in my page I'm getting:

In Reply To:
<img src="/img/icons/.jpg" border=0>
There's no ID before the .jpg

Here's the relevant stuff in my sub site_html_print_cat:

In Reply To:
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, $catimage, $subcat, $category_name, $description, $output, $i, @subcatsub, $length, $s);
my $half = sprintf("%.0f", ($#subcat+2)/3);
my $id = $rec{'ID'};
and
In Reply To:
### Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<a href="$url"><img src="/img/icons/$id.jpg" border=0></a><BR>|;
$output .= qq|<dl><font face=arial size=2><b><a href="$url">$category_name</a></b></font><BR>|;
How can I get the Category ID to carry over to the HTML output so that I can pull up the pics?

Many thanks.

DT

Quote Reply
Re: Graphics for Category Names In reply to
Success !!

I found how to implement Widgetz' and AnthroRules' suggestions, and it's very simple. Using the ID is the best way because if you have complex category names, like Bausch_&_Lomb, the browser screws these up.

In site_html_templates.pl

Go To sub site_html_print_cat

Just below this:

In Reply To:
# 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];
Add this:

In Reply To:
($id) = @{$category{$subcat}}[0];
Make sure that the number within the [ ] brackets refers to your ID field.

Next, just below:
In Reply To:
# Then we print out the name linked, new if it's new, and popular if its popular.
Add (and configure to your site):
In Reply To:
$output .= qq|<center><a href="$url"><img src="/images/icons/$id.jpg" border=0></a>
|;
I use .jpg files, but you should rename to fit yours. Then, grab the image files that you want to use, rename them according to their respective category id (like 3.jpg, 24.jpg, 135.jpg), load them into your icon directory (or whatever dir you're using), and rebuild. Works great for me.

Hope this helps! Smile



Quote Reply
Re: Graphics for Category Names In reply to
I did it this way and it works a treat only requires adding one line into the text too have random images, name all your .gifs the same as your cat headings and hey presto

# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<dl><dt><strong><img border="0" src="http://www.yourpage.com/pages/$category_name.gif" width="32" height="32"><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 .= "<BR>\n";
$output .= qq|</dt>|;
$output .= qq|<span class="descript">$description </span>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;
}

# Don't forget to end the unordered list..

Quote Reply
Re: Graphics for Category Names In reply to
I would recommend not using a volatile field like Name (category_name) for the image. What you should use is the ID field defined in the category.def file.

What are you going to do if the category_name (Name) changes? Not really efficient to use the category_name variable.

Regards,

Eliot Lee
Quote Reply
Re: Graphics for Category Names In reply to
Anthro I can see what you are saying, but I have 8 category headings e.g
heading 1 , heading 2 etc etc and then I have created 8 images called heading1.gif, hjeading2.gif. Therefore in the future if I decide to add another category I will also have too add another image file, but that only takes 2 seconds.

Quote Reply
Re: Graphics for Category Names In reply to
What happens if you forget to re-name the image? Huh? Using non-unique and volatile/dynamic fields to name variables and image files is not good programming logic at all, IMHO.

Regards,

Eliot Lee
Quote Reply
Re: Graphics for Category Names In reply to
I have found 'Dogtags' Id method works but -
1. I have the graphical categories showing + the html category links..is there a way to just have the graphics only...

2 . I just want graphical category headers on the homepage ONLY... I just have 2 main category names ( that will never change), but after the homepage I want to just use html...is this possible?












Quote Reply
Re: Graphics for Category Names In reply to
1. Just delete the $category_name tag from the print cat sub.

2. Yes been discussed before, try searching the forum.

Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Graphics for Category Names In reply to
I've had a look, but couldn't find anything - do you know the thread? could you post where it is? cheers...

Quote Reply
Re: Graphics for Category Names In reply to
Copy the print cat sub in site html templates.pl and name it sub site_html_print_cat2 (this second one determines how your main page looks, the first controls how your category pages look).

Then go into nph_build.cgi find in the sub build home page:

$category = &site_html_print_cat (@rootcat) if ($#rootcat >= 0);

Replace it with:

$category = &site_html_print_cat2 (@rootcat) if ($#rootcat >= 0);


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Graphics for Category Names In reply to
Hi all,
I see this thread is very large an diverse,
It take me a little bit to find the right mix of ideas
to do it work (for my proyect).
Finally i decided to use one of the combinations and it works great, so I post this message to help others looking to install this mod.
I have installed mod suggested by:
Floristan (Stranger)
Posted on 17-May-00 10:19 AM

PLUS suggestion sent by: AnthroRules (Veteran)
Posted on 17-May-00 08:15 PM

hope this helps
THANK YOU VERY MUCH FLORISTAN AND ANTHRORULES ;-)

regards
polete


Quote Reply
Re: Graphics for Category Names In reply to
Can anyone combine these posts into an easily readable and implementable solution for this layman to understand more clearly?

I read the posts mentioned above but I'm having trouble interpreting them.
Thanks in advance to anyone who can help.

Terry

Quote Reply
Re: Graphics for Category Names In reply to
Yeah, me too. And if there is a site that can be reffered to it would be even better.
Thanks.

Quote Reply
Re: Graphics for Category Names In reply to
there this site which has what you want, it just uses a one line addition too the script, no cgi experience neccessary

http://www.world-porn.org/cgi/links/

Quote Reply
Re: [glennu] Graphics for Category Names In reply to
How would I apply this to the "What's New" page? I have added a field with a url to the graphic. But I want the image to show next to the name of the category. I do not want the image to show on any other category list.

Thanks
George
> >