Gossamer Forum
Home : Products : Links 2.0 : Customization :

Graphics for Category Names

(Page 1 of 2)
> >
Quote Reply
Graphics for Category Names
Would there be a way to substitute a graphic for the text names of categories on the home page?

Thanks for any help.
Quote Reply
Re: Graphics for Category Names In reply to
That would entail a lot of work and hacking the script.

You'd have to create an associated array that would contain values for text names, then reference the text names in the @category and @sub_category arrays.

Simple answer...not that easy. Impossible...not...But not easy to do...

Do I have time or energy to expend on this type of project?

Nope.

Sorry.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------







Quote Reply
Re: Graphics for Category Names In reply to
And what about not replacing names but adding an icon besides....
IE: Coffee \_/³ ( but a nice icon instead) ;-)
Quote Reply
Re: Graphics for Category Names In reply to
yea it's possible..

it wouldn't take that long

are you looking to use pre-made images or dynamic images?

------------------
Jerry Su
Links SQL User
------------------


[This message has been edited by widgetz (edited January 27, 2000).]
Quote Reply
Re: Graphics for Category Names In reply to
pre-made would be great. thanks, jerry.
Quote Reply
Re: Graphics for Category Names In reply to
can't you just use the id? and put the images in a directory?

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: Graphics for Category Names In reply to
Thanks, Eliot and Jerry! This opens some interesting possibilities. Smile

Do you think this would be worthwhile posting in the Resource Center?

Jerry, what are dynamic images?

Thanks.

[This message has been edited by DogTags (edited January 29, 2000).]
Quote Reply
Re: Graphics for Category Names In reply to
Do you mean to change something in site_html_templates, sub site_html_print_cat,

from
Code:
$output .= qq|<b><font face=verdana,arial size=2><a href="$url">$category_name</a></b></font> <small>($numlinks)</small> |;

to
Code:
$output .= qq|<b><a href="$url"><img src="/images/<%ID%></a> <small>($numlinks)</small> |;

[This message has been edited by DogTags (edited January 28, 2000).]
Quote Reply
Re: Graphics for Category Names In reply to
Actually, you cannot use the <%ID%> tag, but you could use the following:

Code:
$output .= qq|<b><a href="$url"><img src="/images/$id.jpg"></a> <small>($numlinks)</small> |;

Then you would have to define the $id locally with my, like the following:

Code:
my $id = $rec{'ID'};

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. Smile
----------------------










[This message has been edited by Eliot (edited January 28, 2000).]
Quote Reply
Re: Graphics for Category Names In reply to
dynamic images are images created on the fly.. for example.. here is a sorta complex one i made for review.cgi v2..

http://www.pdamania.com/graph.cgi?ID=1002

you could easily make a graphic labeled with the categories name. (in any font.. the graph.cgi uses predefined fonts so the user won't need to install them)..

the thing is that it will take a bit more bandwidth and is usually not cached.. it saves you time though..

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: Graphics for Category Names In reply to
I guess the best application for these is for doing instant updates for graphs, etc.

Thanks for explaining them, Jerry. Smile
Quote Reply
Re: Graphics for Category Names In reply to
I would think you could do this:

$output .= qq|<a class="link" href="$url"><img src$rec{'Category'}.gif"></a> |;

and then make category.gifs.

What I would like to do is to have image subcategories. Any ideas on how to use the above with a few if/else statements -- ie. if category use this $output string else use the other one.
Quote Reply
Re: Graphics for Category Names In reply to
Solution for "my" image subcategories:

if ($subcat =~ "Software") {
$output .= qq|<strong><a class="link" href="$url"><IMG SRC="/software.gif\"></a></strong> |;
}
else {$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong><BR> |;}

----------

I assume that this would also work:


if ($subcat =~ "$category_name") {
$output .= qq|<strong><a class="link" href="$url"><IMG SRC="/$rec{'Category'}.gif\"></a></strong> |;
}
else {$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong><BR> |;}

-------

Actually, the above mod has wide applications for both categories and subcategories. Using a similar setup as the mod for different category templates, a specific category/subcategory or all categories/subcategories can be given graphics, graphic/text combos, etc.

For example, in the site_html_templates.pl file under sub site_html_print_cat:

if ($subcat =~ "Companies") {
$output .= qq| <a class="link" href="$url">$category_name</a> |;
}
elsif ($subcat =~ "Computers/Hardware") {
$output .= qq| <a class="link" href="$url"><img src="hardware.gif"</a> |;
}
elsif ($subcat =~ "Computers") {
$output .= qq|> <a class="link" href="$url">This is the computer textual subcat!</a> |;
}
else {$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong><BR> |;}

or for the main categories:

:

if ($cat =~ "Companies") {
$output .= qq| <a class="link" href="$url">$category_name</a> |;
}
elsif ($cat =~ "Hardware") {
$output .= qq| <a class="link" href="$url"><img src="hardware.gif"</a> |;
}
elsif ($cat =~ "Computers") {
$output .= qq|> <a class="link" href="$url">This is the computer textual subcat!</a> |;
}
else {$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong><BR> |;}

Zaro

[This message has been edited by zaro (edited February 29, 2000).]
Quote Reply
Re: Graphics for Category Names In reply to
I am trying to implement this modification to replace category text links with graphics. I implemented the changes to the site_html_template.pl but when I upload it and try to rebuild it asks me if I wantto download the nph file. Here is what I did:

# Then we print out the name linked, new if it's new, and popular if its popular.
if ($cat =~ "AVS_Sites") {
$output .= qq| <a class="link" href="$url">$category_name</a> |;
}
elsif ($cat =~ "Amateurs") {
$output .= qq| <a class="link" href="$url"><img src="http://www.mantracker.com/links/category_images/amateurs.gif"</a> |;
}

else {$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong><BR> |;}


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

1;

Thanks for your help...
Quote Reply
Re: Graphics for Category Names In reply to
Hi All,

been trying to replace category names with images .. and I have used every syntax version I found here and combinations of.. Smile but cannot get them to display...

Has someone actually got this working?

This is all I end with

[<img src".gif">]

Dave

Quote Reply
Re: Graphics for Category Names In reply to
Is there a definitive solution for this one?

I just found this thread the other day and can't get it working. Both links in the resource center refer to this thread. There seems to be some suggestions for a solution but it ends up with two people having problems implementing them.

Regards

Mike
Quote Reply
Re: Graphics for Category Names In reply to
DDave & Mike, Try this.
All I did was play with it. I have no proof, I have an offline test server!
Hope it works, It does for me!
P.S. Thank the people in this thread, not me.
I take no credit for this code as it is not mine.

if ($subcat =~ "$category_name") {
$output .= qq|<strong><a class="link" href="$url"><IMG border="0"SRC="/path/to/images/$category_name.gif"></a></strong> |;
}
else {$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong><BR> |;}
Quote Reply
Re: Graphics for Category Names In reply to
Thanks.

After I posted my message I thought I'd dive in and give it a go anyway. What I've dome seems to work OK for me so far, can anyone see any likely problems that might crop up?

# Then we print out the name linked, new if it's new, and popular if its popular.
# Commented out by mike
# $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|</dl>|;


########
# Added by Mike - Banks
if ($subcat =~ "Banks") {
$output .= qq|<strong><a class="link" href="$url"><IMG SRC="/graphics/links_banks.gif\" BORDER=0></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|<BR><FONT SIZE=2><span class="descript">$description </span>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;
}
########

etc, etc, for other categories.

else {$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong><BR> |;}
}
Quote Reply
Re: Graphics for Category Names In reply to
I found this thread this morning in the mods section AFTER struggling with the same problem and coming up with my own solution.

Here's what I did:


Opened category.def and added one field thus:

# Database Definition: CATEGORIES
# --------------------------------------------------------
# Definition of your database file.
Û_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 75, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 75, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', ''],
Icon => [8, 'alpha', 40, 75, 0, 'http://www.barline.com/icons/', '']
);



Then I opened site_html_templates.pl and in sub site_html_print_cat added one if statement:

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

if (@{$category{$subcat}}[8] =~ ".gif") {
$output .= qq|<dl><dt><img src="@{$category{$subcat}}[8]"><a href="$url">$category_name</a> ($numlinks) |;
}
else{
$output .= qq|<dl><dt><a href="$url">$category_name</a> ($numlinks) |;
}
$output .= qq|<small><sup><font color="red">new</font></sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</dt>|;
$output .= qq|<dd><span>$description </span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;


I like my solution because it doesn't require one to code category names into site_html_templates.pl. This maintains maximum flexibility of the database structure. You decide which category gets which icon when adding or modifying categories in the Administrative Control Panel. The URL fragment entered in the field added to the database definition saves typing time when adding records. At that point you will have to type 'youricon.gif'.

The if statement tests for the substring '.gif' in the Icon field, and if it is found prints the contents of field 8 (the Icon field) in an image tag. If it is not found, no image tag is added. This allows you to leave field 8 blank in any records you choose.

I've tested this and it works for me. I hope it is useful to someone else.


Daniela Muhling

Quote Reply
Re: Graphics for Category Names In reply to
One suggestion for your code hack....

Rather than putting the URL to the icon directory in the default value column in the Icon field, I would recommend doing the following:

1) Create the following variable in the links.cfg file:

Code:
$db_icon_dir = "http://www.yourdomain.com/icons";
2) Then change the following codes:

Code:
<img src="@{$category{$subcat}}[8]">
with the following codes:

Code:
<img src="$db_icon_dir/@{$category{$subcat}}[8]">
This will save data in the categories.db file.

Regards,



Eliot Lee
Anthro TECH, L.L.C
Web: http://www.anthrotech.com/
Quote Reply
Re: Graphics for Category Names In reply to
Hi

Sorry to bring this up again, but I have tried to implement some of the mods and I am having little or no luck.

But I found that if I simply enter the following

$output .= qq|<font face="Verdana,Sans-Serif" size="-2"><dl><a href="$url"><img src="/links/images/$category_name.gif" border="0"></a>

You can give the graphic the same name as the category - great - well not quite as category_clean removes the _ between words, would it not be simpler to add to the following line at the start of the sub

my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);

can we not add a scalar that has the category name with the underscore. I beleive there is one in other parts of links.

Or can we not add a line that will will take $url and take the directory name from the end - obviously I am not a perl programmer, but I feel that this would save altering other files, and make the graphics easier to understand using a name as opposed to number.

Your views would be appreciated.

Thanks

DavyC

Quote Reply
Re: Graphics for Category Names In reply to
I've tried implementing several of these mods that I've seen on different posts but am not having much luck.
I simply want to add an image next to the category name on the homepage, dependant upon the category.

ex.
[image 1] [category 1]
[image 2] [category 2]
[image 3] [category 3]

any help would be appreciated.

Courtney

Quote Reply
Re: Graphics for Category Names In reply to
ok, I figured this out. Just needed a little more thought process on my part to figure out how to customize to include graphics with title vs. replacing title.

Quote Reply
Re: Graphics for Category Names In reply to
Does the images appear also next to the subcategories if you like.?
Is it a static image or a hyperlink?

Thank you..
Mark

Quote Reply
Re: Graphics for Category Names In reply to
What did you do to get this working, nubianz?

I would like to get this to work on category names in the category list on the home page and on subcat names in the subcategory lists on sub pages.

Thanks.

DT

> >