Re: [SMARTY] More newbie questions

From: Date: Mon, 26 Jan 2004 19:49:12 +0000
Subject: Re: [SMARTY] More newbie questions
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10876@lists.php.net to get a copy of this message
Le 26 janv. 04, à 20:11, Robin Kopetzky a écrit :
Good afternoon! In my converting this program, I have many places in the original 'template' file that are like this: example 1) <TD><?php echo SomeFunction($blah, $foo, $bar); ?><TD> or example 2) <?php require "some_file.php"; ?> Do I use {php}blah-blah{/php) on the first example and {include file="some_file.php") on the second or is there a better way? Robin,
They are several ways to do that, following are tow of them (they are probably others) Way #1 ---------- somewhere in your application myusefullfucntions.php .. fantastic code.... myfunction($blah, $foo, $bar) { } index.php <?php include 'myincludepath/myusefullfunctions.php'; .... some code.... $smarty->assign('resultOfMyFunction', myfunction($blah, $foo, $bar)); index.tpl <html> ... some html... <td>$resultOfMyFunction</td> (or a foreach, or a section depending what you intend to do) way #2 ---------- somewhere in your plugins directories function smarty_function_myMarvelousFunction($params, &$smarty) { if ( isset($params['foo']) && isset($params['blah']) && isset($params['bar'])) { .. do a lot of fantastic stuff } } ?> index.tpl <html> ... some html... <td>{ myMarvelousFunction blah=$smarty.get.blah foo=$smarty.get.foo bar=$smartty.get.bar}</td> Hope this helps Luc

« previous php.smarty.general (#10876) next »