Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Calling a plugin function in if?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
sirshruf
Smarty n00b


Joined: 06 May 2009
Posts: 1

PostPosted: Wed May 06, 2009 12:28 pm    Post subject: Calling a plugin function in if? Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed May 06, 2009 5:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
pcoldrey
Smarty n00b


Joined: 23 Feb 2011
Posts: 1

PostPosted: Wed Feb 23, 2011 4:43 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP