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
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