Re: [SMARTY] Including modules

From: Date: Fri, 15 Apr 2005 20:22:12 +0000
Subject: Re: [SMARTY] Including modules
References: 1 2 3 4  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12515@lists.php.net to get a copy of this message
I figured that... *shrug* Here's what I've done on header.tpl {top_nav} then in plugins/function.top_nav.php function smarty_function_top_nav($params, &$smarty) { include('top_nav.php'); } then on top_nav.php $smarty->display('top_nav.tpl'); and tried $this->display('top_nav.tpl'); errors are smarty: Fatal error: Call to a member function display() on a non-object... this: Fatal error: Using $this when not in object context in... you're probably wondering, why don't I just put my logic in the smarty_function_top_nav function like it's supposed to be... well answer is because I want application specific code in the same directory...I'll only be giving write permissions to a specific directory to future developers... so I don't want them worry about Smarty... just pretty much running middle tier code... *shrug* > FYI, when you are inside of something like {php_include}, the proper > object name is $this->func(), not $smarty->func(). > > Jonathan Villa wrote: > >>>why not refactor these 3 as smarty plugins... >>>then you can do stuff like: >>> >>>header.tpl >>>----------- >>>{top_nav} >>>{left_nav} >>>{right_nav} >>> >>> >>>take a look at the files in the plugins dir of smarty for info >>>on how to write a smarty function/plugin. >>> >>> >>> >>I did exactly that but I kept getting an error about $smarty-> not being >>instantiated... you know the error "xxxon a non object" >> >>I'm instantiating it in file called app-config.inc that get's prepended to all >>application files... that setup has worked for months... just get an error when >>trying to use it in a smarty plugin. >> >> >> > >

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