Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Category Menu Everywhere with Image

Quote Reply
Category Menu Everywhere with Image
Hello all,

Below is the global tag for show top category in any page, my question is, how to show the image next to category name to this global tag, for the information i already set the image for every category and its work at <%category%>

Please help

Code:
Category_Menu =>
sub {
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options("ORDER BY Full_Name");
my @root_cats = $cat_db->select (['Full_Name'], { FatherID => 0 })->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<a href="$CFG->{build_root_url}/$url">$root_cat</a><br>~;
}
return $output;
}
Quote Reply
Re: [reenee] Category Menu Everywhere with Image In reply to
You know the category_id, so why not use that to link a file where the graphic was named for the category, ie: category_id.gif

Put the files in the same location (directory) and then you can link to them <img src=/path/to/image/file/<%category_id%>.gif>


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Category Menu Everywhere with Image In reply to
Hi pugdog,

Thanks for help, but it doenst show an image, please help.

Code:
sub {
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options("ORDER BY Full_Name");
my @root_cats = $cat_db->select (['Full_Name'], { FatherID => 0 })->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<img src="$CFG->{build_images_url}/icon/<%category_id%>.gif"><a href="$CFG->{build_root_url}/$url">$root_cat</a><br>~;
}
return $output;
}
Quote Reply
Re: [reenee] Category Menu Everywhere with Image In reply to
Hi Renee,

What pugdog means is i quess;

Put: <img src=/path/to/image/file/<%category_id%>.gif> in your template file.

U dont have to change anything in the sub.

Hopes that helps...
Quote Reply
Re: [startpoint] Category Menu Everywhere with Image In reply to
Thanks startpoint,

I think there was a misunderstanding from my first thread, its because of my poor english and i'm very sorry for that, normally by global tag below, it only list all the main category, but what i need is a little modification with this global tag, that will show an image next to every category name listed.

What i mean 'image' is, i already have the specific image for each category by creating a new column at Category=>Properties=>Image

Please help ...

Code:
Category_Menu =>
sub {
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options("ORDER BY Full_Name");
my @root_cats = $cat_db->select (['Full_Name'], { FatherID => 0 })->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<a href="$CFG->{build_root_url}/$url">$root_cat</a><br>~;
}
return $output;
}
Quote Reply
Re: [reenee] Category Menu Everywhere with Image In reply to
 
$output .= qq~<img src="$CFG->{build_images_url}/icon/<%category_id%>.gif"><a href="$CFG->{build_root_url}/$url">$root_cat</a><br>~;


I think it's how you look at it, which will work better, but you can replace the <%category_id%> with the name of the image file. Where you put the image file, would determine how you would link it.

If you use a consistent naming convention, using the category_id to name the image, then you can always find the image as <%category_id%>.gif or $tags->{'ID'} . '.gif'


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Category Menu Everywhere with Image In reply to
Thanks pugdoq, i did it.

The next problem is, how can i show the number of links and the category description next to category name, see the tag below.

Somebody please help me...


Code:
sub {
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options("ORDER BY Full_Name");
my @root_cats = $cat_db->select (['Full_Name'], { FatherID => 0 })->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~
<tr>
<td valign=top>
<img src="$CFG->{build_images_url}/icon/$root_cat.gif">
</td>
<td valign=top>
<a href="$CFG->{build_root_url}/$url"><font face="MS Sans Serif" size="1"><b>$root_cat</b></a>
<font face="Arial" size="1">$CFG->{Number_of_Links}</font>
<br><font face="Arial" size="1">$CFG->{Description}
</font>
</td>
~;

}
return $output;
}

Last edited by:

reenee: Mar 24, 2002, 6:26 AM