|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
TedK Smarty n00b
Joined: 12 Sep 2019 Posts: 4
|
Posted: Thu Sep 12, 2019 1:13 pm Post subject: Smarty_Internal_Method_Register_Object |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Sep 14, 2019 5:43 am Post subject: |
|
|
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 |
|
TedK Smarty n00b
Joined: 12 Sep 2019 Posts: 4
|
Posted: Sun Sep 15, 2019 5:51 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Sep 15, 2019 9:02 pm Post subject: |
|
|
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 |
|
|
|
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
|