Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Image call on category page

Quote Reply
Image call on category page
Hello,

I haev searched and found threads on the subject, but nothing that works for me. Unsure So, I ask for help.

I created a new column in the categories table for an image. It is called "image_cat"

Via the admin, I have uploaded images for subcategories. They reside in a directory inside the build_root_url. So if the build_root_url is "content" then the files are stored here:
/content/image_cat/

I go to my subcategory.html template and add:

<%if image_cat%>
<img src="<%build_images_url%>/<%image_cat%>">
<%endif%>

and I get a broken image. What am I doing wrong? I am hoping to not have the images called by cgi, rather to only be accessible via .html pages. Can you help?

Last edited by:

Evoir: Aug 6, 2002, 8:07 PM
Quote Reply
Re: [Evoir] Image call on category page In reply to
you need to make a global that will call the image - putting the column name doesn't work straight out of the box (at least not that I've found). This is what I've got for the global...

name: hiresimage


Code:
sub {
my $tags = shift;
my $file = $DB->table('Links')->file_info ('Image', $tags->{ID});
my ($url) = $file =~ m,/mnt/raid/www/lsql/pages/images/links/hi-res/(.*),;
return $url;
}

then you just use the tag..

Code:
<% hiresimage %>

in your templates where the image name should be.

That works to display files for each of my "links" - you'll need to adapt it to work with your colums, but it's only a matter of changing which field get called in the code and putting in the right path to your images.

hope that helps!

regan.

Last edited by:

ryel01: Aug 6, 2002, 8:15 PM
Quote Reply
Re: [ryel01] Image call on category page In reply to
hmmm. I have been able to add an image call to the links without the use of a global. I am running LSQL2.11 (I think in the past you had to use a global)

But for links, I just created a column in the links table and called it via the template.

I will try what you suggest, but isn't there a more direct route?
Quote Reply
Re: [Evoir] Image call on category page In reply to
I have found this thread, but I cannot make the suggestions work. Unsure
http://www.gossamer-threads.com/...egory%20page;#197980
Quote Reply
Re: [Evoir] Image call on category page In reply to
Talking to myself Wink

So, What I am hoping to do is just do a call that in effect is showing this path:

<%if image_cat%>
<img src="/content/image_cat/11-12_3.jpg">
<%endif%>

with the part in bold being replaced with a variable. I thought it would be easily replaced with whatever I named my column to be. My column is named <%image_cat%> as is my directory that is storing images for this column via the upload in the admin.

So close....
Quote Reply
Re: [Evoir] Image call on category page In reply to
So, when I just put the tag<%image_cat%> on the subcategory.html template, the correct filename get's printed on the page, like "07_4.jpg"

So, I tried giving it a path:
<img src="/content/image_cat/<%image_cat%>">

or even:
<img src="<%build_images_url%>/<%image_cat%>">

Last edited by:

Evoir: Aug 6, 2002, 11:00 PM
Quote Reply
Re: [Evoir] Image call on category page In reply to
If you would like it as a static link to the category image, then try this global:

Code:
sub {
my $tags = shift;
my $tbl = $DB->table( 'Category' );
my $fh = $tbl->file_info( 'Image', $tags->{ID} );
my $link = "/content/image_cat".$fh->File_RelativePath();
undef $fh;
return $link;
}

Regards,
Chanelle
-- Gossamer Threads, Inc.