Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: [afinlr] Header Image for Main Categories

Quote Reply
Re: [afinlr] Header Image for Main Categories In reply to
Ok so many thanks to Laura for this works fine.

Global provided by Laura :
I called it "get_cat_image" (as Laura suggests)

sub {
my $tags = shift;
if ($tags->{Category_Image}){return $tags->{Category_Image};}
else {
my $cat = $tags->{Full_Name};
$cat =~ s,^([^/]+)/.*$,$1,;
my $cat_db = $DB->table('Category');
my $image = $cat_db->select ( { FatherID => 0, Full_Name => $cat}, ['Category_Image'] )->fetchrow_array;
return $image;
}
}


On the category template I use this at the top of the page to display a category header :
<%if get_cat_image%>
<img src="<%build_images_url%>/header_image/<%get_cat_image%>" border=0 />
<%endif%>



For the detailed page I add this global by Andy and specifically modified by Laura :
I called it "detail_father_id"

sub {

my $ID = $_[0];
my $table = $DB->table('CatLinks');
my $sth = $table->select( { LinkID => $ID } ) || return "Error: $GT::SQL::error";

my $CatID;
while (my $hit = $sth->fetchrow_hashref) {
$CatID = $hit->{CategoryID};
}

my $table = $DB->table('Category');
my $sth = $table->select( { ID => $CatID } ) || return "Error: $GT::SQL::error";

my ($FatherID,$Full_Name,$CatIm);
while (my $hit = $sth->fetchrow_hashref) {
$FatherID = $hit->{FatherID};
$Full_Name = $hit->{Full_Name};
$CatIm = $hit->{Category_Image};
}


return { FatherID => $FatherID, Full_Name => $Full_Name, $CatIm => $CatIm }

}


Then in the detailed.html page I insert at the top of the page to display a category header :
<%detail_father_id($ID)%>
<%if get_cat_image%>
<img src="<%build_images_url%>/header_image/<%get_cat_image%>" border=0 />
<%endif%>

Obviously all this depends on having created an image field in the category table that in this example is called "Category_Image"
So far I haven't figured out how to get the hashed referenced path to the file so I just put via FTP in a folder called "header_image" thus the code :
<img src="<%build_images_url%>/header_image/<%get_cat_image%>" border=0 />

This may not be as clear as I think it is so please ask if it's not clear !

John

PS : just so that you know <%get_cat_image%> produces the name of the image file (without the path) and <%detail_father_id($ID)%> produces no visible output (it gets the fatherID that isn't otherwise called on the detailed.html page) in case you're expecting something else !
Significant Media
Subject Author Views Date
Thread Header Image for Main Categories Jag 4961 Nov 19, 2004, 7:46 PM
Thread Re: [Jag] Header Image for Main Categories
afinlr 4809 Nov 20, 2004, 9:44 AM
Thread Re: [afinlr] Header Image for Main Categories
Jag 4824 Nov 20, 2004, 10:04 AM
Thread Re: [Jag] Header Image for Main Categories
afinlr 4797 Nov 20, 2004, 10:15 AM
Thread Re: [afinlr] Header Image for Main Categories
Jag 4807 Nov 20, 2004, 10:21 AM
Thread Re: [Jag] Header Image for Main Categories
afinlr 4806 Nov 20, 2004, 12:00 PM
Thread Re: [afinlr] Header Image for Main Categories
Jag 4790 Nov 20, 2004, 8:45 PM
Thread Re: [Jag] Header Image for Main Categories
afinlr 4772 Nov 21, 2004, 7:20 AM
Thread Re: [afinlr] Header Image for Main Categories
Jag 4780 Nov 21, 2004, 11:18 PM
Thread Re: [Jag] Header Image for Main Categories
afinlr 4771 Nov 22, 2004, 3:40 AM
Thread Re: [afinlr] Header Image for Main Categories
Jag 4747 Nov 23, 2004, 2:37 PM
Thread Re: [Jag] Header Image for Main Categories
afinlr 4787 Nov 23, 2004, 2:55 PM
Post Re: [afinlr] Header Image for Main Categories
Jag 4758 Nov 23, 2004, 3:06 PM
Post Re: [afinlr] Header Image for Main Categories
Jag 4738 Nov 24, 2004, 2:24 AM
Thread Re: [afinlr] Header Image for Main Categories
Jag 4654 Jul 30, 2005, 6:02 PM
Thread Re: [Jag] Header Image for Main Categories
afinlr 4645 Jul 31, 2005, 1:00 PM
Post Re: [afinlr] Header Image for Main Categories
Jag 4632 Aug 1, 2005, 8:04 AM