|
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 |
ThermoDust Smarty Regular
Joined: 10 Sep 2003 Posts: 38
|
Posted: Mon Sep 15, 2003 11:14 pm Post subject: Smarty Plugin in normal PHP |
|
|
Can I call smarty plugin code within my php code? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Sep 15, 2003 11:27 pm Post subject: |
|
|
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 |
|
|
|
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
|