Gossamer Forum
Quote Reply
if then syntax in Global
Hi everybody

i am using the following Global to create a second Category page with Pagebuiler plugin

Is there any possibility to check if the field Image in the Links Table is empty

i don't know the syntaxFrown

like if image =""

then

$output .= qq~<tr><td width="70" rowspan="2"><img border="0" img src="/images/empty.gif" 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>

else

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

the check must be in the global and not in template

please help

Wink Marina


The 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;
}
Quote Reply
Re: [mkoenig] if then syntax in Global In reply to
How about;

Code:
<%if image%>
... show image stuff here
<%else%>
... other stuff
<%endif%>

If 'image' holds a value, then there should be an image for the appropriate link, but if not, it should show the default stuff.

Hope that helps Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] if then syntax in Global In reply to
hi Andy

is there an possibility to check the image field in the global

Marina
Quote Reply
Re: [mkoenig] if then syntax in Global In reply to
Could you explain a bit more about what this global is meant to do? It looks like it could be re-written to about 5-10 lines (if its doing what I think it is)....

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] if then syntax in Global In reply to
Hi Andy

the result of the global is a table

first row Image, second row title an link and last row Category

loop 10 times

the problem is that only some links have images

now the result in the Page have many imageserrors

TongueMarina
Quote Reply
Re: [mkoenig] if then syntax in Global In reply to
How about this?

Code:
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'});

if ($link->{'image'}) {

$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> ~;

} else {

$output .= qq~<tr><td width="70" rowspan="2"><img border="0" img src="/images/empty.gif" 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>
~;

} # end 'if'
} # end while


return $output;


}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] if then syntax in Global In reply to
SlySlySlyHi Andy

Thank you very much for your help

you are the best

Marina