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

Can't get Smarty to register new plugin
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
strafford
Smarty Rookie


Joined: 27 Jun 2018
Posts: 17

PostPosted: Mon Feb 11, 2019 2:49 pm    Post subject: Reply with quote

AnrDaemon wrote:
Sorry, the archiver says the file is incomplete.


https://drive.google.com/open?id=1zB_bR5XXbznCvjvtqQo-9UXwONkMDtfB
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1545

PostPosted: Mon Feb 11, 2019 10:41 pm    Post subject: Reply with quote

Works like a charm, just as I said.

https://github.com/AnrDaemon/test-001/blob/forum-27741/testcase.php

Code:
$ testcase.php
Hello
This is not translated
This is translated
blah

PHP: 7.1.26
Smarty: 3.1.34-dev-7
Back to top
View user's profile Send private message
strafford
Smarty Rookie


Joined: 27 Jun 2018
Posts: 17

PostPosted: Tue Feb 12, 2019 1:16 pm    Post subject: Reply with quote

AnrDaemon wrote:
Works like a charm, just as I said.


Yes, when calling the local one, but when you try and call the plugin you get the error.

Code:
$smarty->registerPlugin('block', 't', 'smarty_block_t');


Error:
Plugin 't' not callable
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1545

PostPosted: Tue Feb 12, 2019 1:57 pm    Post subject: Reply with quote

Both works, if you did not notice.
Fetch the forum-27741 branch and run testcase yourself.
Back to top
View user's profile Send private message
strafford
Smarty Rookie


Joined: 27 Jun 2018
Posts: 17

PostPosted: Tue Feb 12, 2019 2:33 pm    Post subject: Reply with quote

AnrDaemon wrote:
Both works, if you did not notice.
Fetch the forum-27741 branch and run testcase yourself.


Not for me:
Code:
Fatal error: Uncaught --> Smarty: Plugin 't' not callable <-- thrown in /usr/local/php5/lib/php/Smarty/sysplugins/smarty_internal_method_registerplugin.php on line 50


PHP: 5.6.40
Smarty: 3.1.33
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1545

PostPosted: Wed Feb 13, 2019 3:42 pm    Post subject: Reply with quote

Then fix your layout or Smarty initialization.
You have a working example before you, step through it with a debugger and see how it differs from your code.
Back to top
View user's profile Send private message
strafford
Smarty Rookie


Joined: 27 Jun 2018
Posts: 17

PostPosted: Wed Feb 13, 2019 9:34 pm    Post subject: Reply with quote

AnrDaemon wrote:
Then fix your layout or Smarty initialization.
You have a working example before you, step through it with a debugger and see how it differs from your code.


Well it is actually working (I added all the required directories and po/mo files) and it is actually translating correctly.

BUT I still get the same error. So do you not need to register the plugins? If I comment out the registerPlugin call it works fine. How do you know when to and when not to?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1545

PostPosted: Thu Feb 14, 2019 1:07 am    Post subject: Reply with quote

You need to EITHER
a) load the file defining the necessary callable and register plugin
OR
b) place the specifically named file defining a specifically named callable into one of the configured Plugins directories.

NOT both.
See https://github.com/AnrDaemon/test-001/tree/forum-27741 for details.
Back to top
View user's profile Send private message
strafford
Smarty Rookie


Joined: 27 Jun 2018
Posts: 17

PostPosted: Thu Feb 14, 2019 1:59 pm    Post subject: Reply with quote

AnrDaemon wrote:
You need to EITHER
a) load the file defining the necessary callable and register plugin
OR
b) place the specifically named file defining a specifically named callable into one of the configured Plugins directories.

NOT both.
See https://github.com/AnrDaemon/test-001/tree/forum-27741 for details.


Ok, so if the function was NOT called smarty_block_t, then I would have to use registerPlugin(). It was not clear (at least to me) from the docs. I was thinking it had to be in a plugin dir, and then registered.

Thank you!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Installation and Setup 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