|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
sirshruf Smarty n00b
Joined: 06 May 2009 Posts: 1
|
Posted: Wed May 06, 2009 12:28 pm Post subject: Calling a plugin function in if? |
|
|
Hi, I need to be able to give a logival operation on a return of a plugin I made...
The return is simply a string, and I am using it in many places in my aplication, so I dont want to rewrite it to return info via assign,
I have tried something like that, but not help.
Code: | { if `getpaddedcolomn index="`$smarty.section.foo.index`" prefix="LNKM" array="entry"` ne "" } |
Please help |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed May 06, 2009 5:13 pm Post subject: |
|
|
You can not embed plugin calls in the if condition. But you could modify your pluging to use optionally the assign attribue to return your result.
code
Code: | if (!empty($params['assign'])) {
$smarty->assign($params['assign'], $_result);
return;
} else {
return $_result;
}
|
|
|
Back to top |
|
pcoldrey Smarty n00b
Joined: 23 Feb 2011 Posts: 1
|
Posted: Wed Feb 23, 2011 4:43 am Post subject: |
|
|
In some cases you can work around this by passing the condition to the template using an Assign in the calling PHP script.
For example:
In the PHP file,...
$smarty->Assign('logged_in', LoggedIn());
In template file,...
{if $logged_in}do some stuff{/if}
Of course this doesn't really help you if you are trying to pass smarty variables into the function,.. which it looks like you might be doing? |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|