Gossamer Forum
Quote Reply
if image field empty
I am usung this global

but my problem is thas some links has no Image

if there is no image i want to show a default image

how can i solve this problem?

Global:

sub {
my $tags = shift;
my $cat = $tags->{'Full_Name'};
my $output;
my $sth;
my $link;

use GT::SQL::Condition;

my $search_db = $DB->table('Links','CatLinks','Category');
$search_db->select_options ('GROUP BY LinkID ORDER BY Add_Date DESC Limit 10');
$sth = $search_db->select (['Links.ID', 'Links.Description', 'Links.Title', 'Links.image', 'Category.Full_Name', 'Category.Name'], GT::SQL::Condition->new(['Full_Name', 'LIKE', $cat .'%'], ['isValidated', '=', 'Yes']));

while ($link = $sth->fetchrow_hashref)
{
# Set the category url
my $category_url = $DB->table('Category')->as_url($link->{'Full_Name'});

$output .= qq~<tr><td width="70" rowspan="2"><img border="0" img src="$link->{'image'}" width="70"></td>
<td width="50%"><a href="$detailed_url"><b>$link->{'Title'}</b></a></td>
<td width="50%"><a href="$CFG->{build_root_url}/$category_url/">$link->{'Name'}</a></td>
</tr>
~;
}

return $output;
}

marina
Quote Reply
Re: [mkoenig] if image field empty In reply to
Hello,

if you store all images in the same directory or subdir you can use a .htaccess file.

Store are .htaccess file with the following content in the image directory

ErrorDocument 404 http://yourdomain/..._to/defaultimage.gif

Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [mkoenig] if image field empty In reply to
Try putting the following code into your template where you want the image to show:

Code:




<%if image%>
<a href="<%URL%>"><img src="<%image%>" align=left vspace=5 hspace=5 border="0" width="200" height="150"></a>
<%endif%>
<%ifnot image%>
<a href="<%URL%>"><img src="<%noimage%>" align=left vspace=5 hspace=5 border="1" width="200" height="150"></a>
<%endif%>


Add a global called noimage and just put in the URL of your default image there.

=)
Quote Reply
Re: [Sugaar] if image field empty In reply to
Hi

I need a code to put in the global that check the image field in Links Table

Marina