Page 1 of 1

Smarty plugin_dir?

PostPosted: Sat Apr 14, 2012 12:40 am
by 00Davo
Does Xataface have provision for a top-level Smarty plugin directory, in the same sense as it has a Smarty templates directory at $SITE_ROOT/templates?

As far as I can tell through scouring the codebase, the only plugin directory made available is the default Smarty one, which resides in xataface/lib/Smarty/plugins. I'd prefer, if possible, for my custom application to reside only in $SITE_ROOT, not within the xataface/ package, so I'd like to keep my plugins out of that provided directory.

So, is there something like $SITE_ROOT/plugins available? If not, could this be added?

Re: Smarty plugin_dir?

PostPosted: Sun Apr 15, 2012 10:08 am
by shannah
There is no provision for a smarty plugins dir outside of the default one. I have wanted to do this for a while, but it hasn't come to the top of my list ever. If you can see an easy way to do this, please post.

_Steve

Re: Smarty plugin_dir?

PostPosted: Sun Apr 15, 2012 9:10 pm
by 00Davo
I took a quick gander through the Smarty documentation, and found that there is in fact a very easy way to do it: just like $smarty->template_dir, $smarty->plugins_dir is permitted to be an array of plugin directories. Thus, $SITE_ROOT/plugins will work as a Smarty plugins directory with the following additions:

Dataface/Globals.php
Code: Select all
# line 25
$GLOBALS['Dataface_Globals_Local_Plugins'] = DATAFACE_SITE_PATH."/plugins";


Dataface/SkinTool.php
Code: Select all
   # line 126
   $this->register_plugins($GLOBALS['Dataface_Globals_Local_Plugins']);

   # line 370
   function register_plugins ( $plugin_dir ) {
      if ( !is_array($this->plugins_dir) ){
         if ( strlen($this->plugins_dir) > 0 ){
            $this->plugins_dir = array($this->plugins_dir);
         } else {
            $this->plugins_dir = array();
         }
      }
      array_unshift($this->plugins_dir, $plugin_dir);
   }


(The definition of register_plugins is almost identical to the definition of register_skin, so it may be prudent to factor out the duplication)

Having made these two alterations to my Xataface codebase, I can verify that this enables $SITE_ROOT/plugins as a working Smarty plugin directory.

Re: Smarty plugin_dir?

PostPosted: Mon Apr 16, 2012 12:42 pm
by shannah
Thanks for posting this. I have added these changes to SVN (rev 3520) and they will be included in the 2.0 release. 1.3.x and 1.5.x will need to follow your directions to patch their versions if they wish to have these changes.

I have also posted information on this in the Wiki at http://xataface.com/wiki/xataface_templates

-Steve