Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty_Internal_Method_Register_Object

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
TedK
Smarty n00b


Joined: 12 Sep 2019
Posts: 4

PostPosted: Thu Sep 12, 2019 1:13 pm    Post subject: Smarty_Internal_Method_Register_Object Reply with quote

Hello,

I am new to the use of objects and functions with Smarty. So I follow the documentation and simply started with this:

Code:
   class My_Object {
      function meth1($params, &$smarty_obj) {
         return 'this is my meth1';
      }
   }

   require_once __DIR__.'/vendor/autoload.php';

   $smarty = new Smarty;
   $myobj = new My_Object;

   // registering the object (will be by reference)
   $smarty->register_object('foobar',$myobj);


This give the following notification followed by a fatal error:

Code:
Notice: Undefined property: Smarty_Internal_Undefined::$objMap in /home/svn/ucodiacms/trunk/vendor/smarty/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 132

Fatal error: Uncaught --> Smarty: undefined extension class 'Smarty_Internal_Method_Register_Object' <-- thrown in /home/svn/ucodiacms/trunk/vendor/smarty/smarty/libs/sysplugins/smarty_internal_undefined.php on line 62


Smarty is installed via composer an the standard things with the templates work fine. Can someone explain what I am doing wrong here?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Sep 14, 2019 5:43 am    Post subject: Reply with quote

1. You don't need it if you want to use its methods in a template.
2. Make sure you're using last released Smarty version.
(3.1.33 at the moment of writing), and it is properly installed.
Back to top
View user's profile Send private message
TedK
Smarty n00b


Joined: 12 Sep 2019
Posts: 4

PostPosted: Sun Sep 15, 2019 5:51 pm    Post subject: Reply with quote

AnrDaemon wrote:
1. You don't need it if you want to use its methods in a template.
2. Make sure you're using last released Smarty version.
(3.1.33 at the moment of writing), and it is properly installed.


1. How do I than make the functions available and accessible in the templates?
2. I use the latest version 3.1.33.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Sep 15, 2019 9:02 pm    Post subject: Reply with quote

TedK wrote:
1. How do I than make the functions available and accessible in the templates?

Just assign your object to the template object.
Quote:
2. I use the latest version 3.1.33.

AnrDaemon wrote:
and it is properly installed.

Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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