Smarty plugin_dir?

A place for users and developers of the Xataface to discuss and receive support.

Smarty plugin_dir?

Postby 00Davo » Sat Apr 14, 2012 12:40 am

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?
00Davo
 
Posts: 55
Joined: Sat Jan 02, 2010 9:02 pm

Re: Smarty plugin_dir?

Postby shannah » Sun Apr 15, 2012 10:08 am

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Smarty plugin_dir?

Postby 00Davo » Sun Apr 15, 2012 9:10 pm

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.
00Davo
 
Posts: 55
Joined: Sat Jan 02, 2010 9:02 pm

Re: Smarty plugin_dir?

Postby shannah » Mon Apr 16, 2012 12:42 pm

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved