Choice between plug in and classical function/class usage ?

From: Date: Wed, 31 Dec 2003 01:34:31 +0000
Subject: Choice between plug in and classical function/class usage ?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10765@lists.php.net to get a copy of this message
Hello, I'm playing with plug in (functions) and find them very cool, so I tried to rewrite a project this way Usually I do // index.php include /somepath/smarty.class.php; include /somepath/mycoolclass.php; ..... switch ($_GET['page']) {
     case 'beer' : $smarty->assign('drink', $mycoolclass->fetchbeer());
	             $smarty->assign('mysubtemplate', 'beverage.tpl');
                        break;
..... $smarty->display('index.tpl'); // index.tpl {include file=$mysubtemplate} //beverages.tpl {$drink} I realize that for display (basically GET db use) I can do exactly the same with plug ins called directly from the template. // index.php include /somepath/smarty.class.php; ..... switch ($_GET['page']) {
     case 'beer' : $smarty->assign('mysubtemplate', 'beverage.tpl');
                        break;
..... $smarty->display('index.tpl'); // index.tpl {include file=$mysubtemplate} // function_getbeverage.php .. some DB calls.. $smarty->assign(......) //beverages.tpl {getbeverage} {$drink} It's easier to use, easier to maintain (if I make a mistake i screw up the plug in and not the entier class) and so on.. But when it comes to performance (server load, time to produce HTML and so on) what is the best way to go ? From my little (local and very limited) testing it seems slower.. is this normal ? Ar there situations where it's better to use the classical way and not plug ins or the opposite, situations where it's better to use plug ins instead of the classical way ? Thanks in advance Luc

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