Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Function plugin not callable

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
ksnyde
Smarty Rookie


Joined: 19 Oct 2012
Posts: 12

PostPosted: Fri Oct 19, 2012 4:09 pm    Post subject: Function plugin not callable Reply with quote

All I want in my current Smarty life is a function plugin that works. I've banged my head a few times and hoping that this forum can help.

I've failed twice: once with an automatic call and now with a runtime registration of the function. I'll describe the latter "runtime registration" failure here.

I have a small object that I use to wrap all smarty objects with so that the appropriate directories are set. This part has worked fine for some while now. What I've added is the registerPlugin call which is gracefully caught and reports the following message:
Quote:
Smarty Error: Plugin "add_ins" not callable.


Here's the code that produced the error:
Code:

class FE_Template
{
   const TEMPLATE_DIR = '/templates/uncompiled';

   public static function init () {
      $object = new Smarty();
      $object->setTemplateDir ( LG_FE_DIR . self::TEMPLATE_DIR );
      $object->setCompileDir ( LG_FE_DIR . '/templates/compiled'  );
      $object->setCacheDir ( LG_FE_DIR . '/templates/cache' );
      $object->setConfigDir ( LG_FE_DIR . '/templates/configs' );
      try {
         $object->registerPlugin ("function","add_ins","smarty_function_add_ins");
      } catch ( Exception $e ) {
         echo "Smarty Error: {$e->getMessage()}";
         echo "<p>Error occurred in: <i>{$e->getFile()}</i> at line <b>{$e->getLine()}</b></p>";
      }
      return $object;
   }
}      


This class's init() function is called with code such as this:

Code:

$page_content = FE_Template::init();
try {
   LG_NutritionalValue::init();
   $user = new LG_User();
   $page = new LG_Page( $user );
   $meta = new LG_Meta();
   $page_content->assign ( 'page' , $page );
   $page_content->assign ( 'user' , $user );
   $page_content->assign ( 'meta' , $meta );
   $page_content->display( "page_sections/master_page.tmpl" );
} catch ( Exception $e ) {
   echo "Smarty Error: {$e->getMessage()}";
   echo "<p>Error occurred in: <i>{$e->getFile()}</i> at line <b>{$e->getLine()}</b></p>";
}   
[/code]
Back to top
View user's profile Send private message
ksnyde
Smarty Rookie


Joined: 19 Oct 2012
Posts: 12

PostPosted: Fri Oct 19, 2012 4:30 pm    Post subject: Addendum Reply with quote

I started thinking maybe my problem was that I hadn't called the setPluginDir() method so I did this:
Code:
$object->setPluginDir ( LG_FE_DIR . '/templates/functions' );


This resulted in a new failure:

Quote:
Uncaught exception 'SmartyException' with message 'property 'plugin_dir' does not exist.


Well that directory DOES exist so I'm really not sure what to make of this message.

I'm struggling. Please help.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7253
Location: Lincoln Nebraska, USA

PostPosted: Fri Oct 19, 2012 7:11 pm    Post subject: Reply with quote

setPluginsDir not setPluginDir, and the actual directly name should be plugins_dir
Back to top
View user's profile Send private message Visit poster's website
ksnyde
Smarty Rookie


Joined: 19 Oct 2012
Posts: 12

PostPosted: Fri Oct 19, 2012 11:25 pm    Post subject: Reply with quote

Ok. Typo removed. I'm now using setPluginsDir() and I've moved to my next failure point ... but it appears I'm making progress. Let me wrestle with this one for a bit. Thanks for the help.

Last edited by ksnyde on Fri Oct 19, 2012 11:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7253
Location: Lincoln Nebraska, USA

PostPosted: Fri Oct 19, 2012 11:28 pm    Post subject: Reply with quote

ksnyde wrote:
Sorry that was a typo on my part. I was using the setPluginDir() function. Based on your suggestion, I changed the actual directory to plugin_dir -- although I wouldn't have thought this should matter -- and same error condition exists.


Still wrong, it is setPluginsDir and plugins_dir
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins 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