Hi,
I'm trying to get a Template Global to return a new tag without displaying anything on my html page but unless I add a second if condition in the sub it always prints the result on my page.
In my footer.html I have the following -
<!--look for record-->
<%record_search%>
<!--if we find a record-->
<%if record_search eq 'yes'%>
do somthing....................
<%endif%>
In my Template globals I have a Code named "record_search" with the following sub in the Description -
sub {
my $tags = shift;
my ($record_search) = $DB->table('contact')->select({'contact_id' => $tags->{Username} }, ['contact_id'])->fetchrow_array();
if ($record_search){
$tags->{record_search}="yes";
}
if ($record_search eq""){
$tags->{record_search}="";
}
}
All I am trying to do is set the value of <%record_search%> to 'yes' if the sql query finds a record and then do something. I DONT want it to print 'yes' on my html page!! I have tried an else condition but it doesn't seem to make any difference.
By adding the second if condition, I have solved the problem but I'm sure there is a better way.
Can anyone help?
Thanks
Simon.
I'm trying to get a Template Global to return a new tag without displaying anything on my html page but unless I add a second if condition in the sub it always prints the result on my page.
In my footer.html I have the following -
<!--look for record-->
<%record_search%>
<!--if we find a record-->
<%if record_search eq 'yes'%>
do somthing....................
<%endif%>
In my Template globals I have a Code named "record_search" with the following sub in the Description -
sub {
my $tags = shift;
my ($record_search) = $DB->table('contact')->select({'contact_id' => $tags->{Username} }, ['contact_id'])->fetchrow_array();
if ($record_search){
$tags->{record_search}="yes";
}
if ($record_search eq""){
$tags->{record_search}="";
}
}
All I am trying to do is set the value of <%record_search%> to 'yes' if the sql query finds a record and then do something. I DONT want it to print 'yes' on my html page!! I have tried an else condition but it doesn't seem to make any difference.
By adding the second if condition, I have solved the problem but I'm sure there is a better way.
Can anyone help?
Thanks
Simon.