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

Smarty Plugin in normal PHP

 
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 -> General
View previous topic :: View next topic  
Author Message
ThermoDust
Smarty Regular


Joined: 10 Sep 2003
Posts: 38

PostPosted: Mon Sep 15, 2003 11:14 pm    Post subject: Smarty Plugin in normal PHP Reply with quote

Can I call smarty plugin code within my php code?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Sep 15, 2003 11:27 pm    Post subject: Reply with quote

Absolutely. You have to make sure you require_once the appropriate plugin and then when you call it you obviously need to use the same calling convention as the function expects. Unless you are calling a modifier, you will need an instance of smarty to pass as well.

- For modifiers, it is as per the modifier function.
- For template functions it is a params array and a smarty object.
- For block functions, it is the params arrays, a content string, the smarty object and starting with 2.6.0+ the repeat flag.

The following shows an example of how to call the mailto plugin.

[php:1:fc19e12109]$smarty = new Smarty;
require_once (SMARTY_DIR . 'plugins/function.mailto.php');
$params = array('address'=>'dev@null.com', 'encode'=>'none');
$result = smarty_function_mailto($params, $smarty);[/php:1:fc19e12109]
Also examine the code for the function you wish to call to ensure you know what the function does in terms of returning data. For example, the function.assign.php updates the passed smarty object without returning results.

HTH
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 -> General 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