View previous topic :: View next topic |
Author |
Message |
neo81 Smarty Rookie
Joined: 06 Sep 2016 Posts: 6
|
Posted: Tue Sep 06, 2016 6:45 pm Post subject: Extended Setup is not working |
|
|
Hello, everybody.
php 5.3
This class
http://www.smarty.net/docsv2/en/installing.smarty.extended.tpl
doesn't work with $this->Smarty(); (PHP Fatal error: Call to undefined method Smarty_GuestBook::Smarty())
Can anyone explain why this example contains it?
Thank you. |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
Posted: Tue Sep 06, 2016 7:47 pm Post subject: |
|
|
Your link points to the manual for Smarty 2.
Do you are using Smarty 2 yet? |
|
Back to top |
|
neo81 Smarty Rookie
Joined: 06 Sep 2016 Posts: 6
|
Posted: Tue Sep 06, 2016 7:50 pm Post subject: |
|
|
Yes, I use Smarty 2 for one of my websites. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Sep 06, 2016 11:05 pm Post subject: |
|
|
Please post complete working script that demonstrates your issue. |
|
Back to top |
|
neo81 Smarty Rookie
Joined: 06 Sep 2016 Posts: 6
|
Posted: Wed Sep 07, 2016 7:41 am Post subject: |
|
|
The code is absolutly the same.
I am just wondering if anybody can comment this line:
$this->Smarty();
"Smarty requires a web server running PHP 4.0.6 or greater." (http://www.smarty.net/docsv2/en/installation.tpl#installation.requirements)
My test machine - CentOS 6.8, php 5.3, httpd 2.2.
So it works but without "$this->Smarty();". Why so? |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
Posted: Fri Sep 09, 2016 7:51 am Post subject: |
|
|
AnrDaemon wrote: | Please post complete working script that demonstrates your issue. |
Can only repeat this! |
|
Back to top |
|
neo81 Smarty Rookie
Joined: 06 Sep 2016 Posts: 6
|
Posted: Fri Sep 09, 2016 9:47 am Post subject: |
|
|
OK.
1. Smarty 2.6.30
cache/
configs/
htdocs/
templates/
templates_c/
2. htdocs/index.php
Code: | require_once('Smarty.class.php');
class Smarty_GuestBook extends Smarty {
function Smarty_GuestBook()
{
// Class Constructor.
// These automatically get set with each new instance.
$this->Smarty();
$this->template_dir = '/var/www/html/mywebsite/templates/';
$this->compile_dir = '/var/www/html/mywebsite/templates_c/';
$this->config_dir = '/var/www/html/mywebsite/configs/';
$this->cache_dir = '/var/www/html/mywebsite/cache/';
$this->caching = true;
$this->assign('app_name', 'Guest Book');
}
}
$smarty = new Smarty_GuestBook();
$smarty->assign('name','Ned');
$smarty->display('index.tpl'); |
PHP Fatal error: Call to undefined method Smarty_GuestBook::Smarty()
3. htdocs/index.php
Code: | require_once('Smarty.class.php');
class Smarty_GuestBook extends Smarty {
function Smarty_GuestBook()
{
// Class Constructor.
// These automatically get set with each new instance.
//$this->Smarty();
$this->template_dir = '/var/www/html/mywebsite/templates/';
$this->compile_dir = '/var/www/html/mywebsite/templates_c/';
$this->config_dir = '/var/www/html/mywebsite/configs/';
$this->cache_dir = '/var/www/html/mywebsite/cache/';
$this->caching = true;
$this->assign('app_name', 'Guest Book');
}
}
$smarty = new Smarty_GuestBook();
$smarty->assign('name','Ned');
$smarty->display('index.tpl'); |
Works. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Sep 09, 2016 11:32 am Post subject: |
|
|
- $this->Smarty();
+ parent::__construct();
http://php.net/OOP |
|
Back to top |
|
neo81 Smarty Rookie
Joined: 06 Sep 2016 Posts: 6
|
Posted: Fri Sep 09, 2016 11:52 am Post subject: |
|
|
AnrDaemon,
Thank you for reply. But my question is why this is in the documentation.
If it's ok please explain how it works. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Sep 09, 2016 12:04 pm Post subject: |
|
|
It IS in the documentation. PHP documentation.
The link is at the bottom of my previous reply. |
|
Back to top |
|
neo81 Smarty Rookie
Joined: 06 Sep 2016 Posts: 6
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Sep 09, 2016 4:15 pm Post subject: |
|
|
That documentation was written for Smarty 2, which was written for PHP4. (Which means, it's old as mammoth's dump.) |
|
Back to top |
|
|