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

Modifier strip_tags
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Sep 24, 2015 7:03 pm    Post subject: Reply with quote

addPluginsDir() does append your custom plugins folder to the search order. So Smarty will find its default modifier first.

Use setPluginsDir() and place you folder first in array().
See http://www.smarty.net/docs/en/api.set.plugins.dir.tpl
Back to top
View user's profile Send private message
ildar
Smarty Rookie


Joined: 14 May 2015
Posts: 14

PostPosted: Fri Sep 25, 2015 6:10 am    Post subject: Reply with quote

U.Tews wrote:
addPluginsDir() does append your custom plugins folder to the search order. So Smarty will find its default modifier first.

Use setPluginsDir() and place you folder first in array().
See http://www.smarty.net/docs/en/api.set.plugins.dir.tpl


Thank you.
Your solution is working

The changed code is

Code:
    public function __construct()
    { //{{{
        parent::__construct();

        $this->setPluginsDir(array_merge(
            array(__DIR__ . '/custom_plugins'),
            $this->getPluginsDir()
        ));
.......


Last edited by ildar on Fri Sep 25, 2015 2:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1583

PostPosted: Fri Sep 25, 2015 9:41 am    Post subject: Reply with quote

ildar wrote:
U.Tews wrote:
addPluginsDir() does append your custom plugins folder to the search order. So Smarty will find its default modifier first.

Use setPluginsDir() and place you folder first in array().
See http://www.smarty.net/docs/en/api.set.plugins.dir.tpl


Thank you.
Your solution is working

The changed code is

Code:
    public function __construct()
    { //{{{
        parent::__construct();

        $this->setPluginsDir(array_merge(
            array(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'custom_plugins'),
            $this->getPluginsDir()
        ));
.......

You know other directory separators, than "/"? Seriously? What OS, may I ask?
Back to top
View user's profile Send private message
ildar
Smarty Rookie


Joined: 14 May 2015
Posts: 14

PostPosted: Fri Sep 25, 2015 11:31 am    Post subject: Reply with quote

You are right

http://stackoverflow.com/questions/6619020/how-can-i-define-the-directory-separator-for-both-windows-and-linux-platform
Quote:


"PHP accepts both \ and / as valid path separators in all OS. So just use / in your code"



but
http://alanhogan.com/tips/php/directory-separator-not-necessary

Quote:

Note that DIRECTORY_SEPARATOR is still useful for things like explode-ing a path that the system gave you.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1583

PostPosted: Fri Sep 25, 2015 2:19 pm    Post subject: Reply with quote

First, it is not "PHP", it is "Operating System" (in this case Windows) don't make a difference between "/" and "\" as path separators.
Second, yes, it is useful, when you are calling system functions and deal with their return values.
Here you are not calling system function.
Third, code readability also matters.
array(__DIR__ . '/custom_plugins')
is more readable, than
array(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'custom_plugins'),
Back to top
View user's profile Send private message
ildar
Smarty Rookie


Joined: 14 May 2015
Posts: 14

PostPosted: Fri Sep 25, 2015 2:41 pm    Post subject: Reply with quote

Your answer is complete.
Thank you for the corrections.

I have changed my sample code
http://www.smarty.net/forums/viewtopic.php?p=89419#89419
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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