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

Extended Setup is not working

 
Post new topic   Reply to topic    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
neo81
Smarty Rookie


Joined: 06 Sep 2016
Posts: 6

PostPosted: Tue Sep 06, 2016 6:45 pm    Post subject: Extended Setup is not working Reply with quote

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
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Tue Sep 06, 2016 7:47 pm    Post subject: Reply with quote

Your link points to the manual for Smarty 2.

Do you are using Smarty 2 yet?
Back to top
View user's profile Send private message
neo81
Smarty Rookie


Joined: 06 Sep 2016
Posts: 6

PostPosted: Tue Sep 06, 2016 7:50 pm    Post subject: Reply with quote

Yes, I use Smarty 2 for one of my websites.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1646

PostPosted: Tue Sep 06, 2016 11:05 pm    Post subject: Reply with quote

Please post complete working script that demonstrates your issue.
Back to top
View user's profile Send private message
neo81
Smarty Rookie


Joined: 06 Sep 2016
Posts: 6

PostPosted: Wed Sep 07, 2016 7:41 am    Post subject: Reply with quote

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
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Fri Sep 09, 2016 7:51 am    Post subject: Reply with quote

AnrDaemon wrote:
Please post complete working script that demonstrates your issue.


Can only repeat this! Rolling Eyes
Back to top
View user's profile Send private message
neo81
Smarty Rookie


Joined: 06 Sep 2016
Posts: 6

PostPosted: Fri Sep 09, 2016 9:47 am    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1646

PostPosted: Fri Sep 09, 2016 11:32 am    Post subject: Reply with quote

- $this->Smarty();
+ parent::__construct();
http://php.net/OOP
Back to top
View user's profile Send private message
neo81
Smarty Rookie


Joined: 06 Sep 2016
Posts: 6

PostPosted: Fri Sep 09, 2016 11:52 am    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1646

PostPosted: Fri Sep 09, 2016 12:04 pm    Post subject: Reply with quote

It IS in the documentation. PHP documentation.
The link is at the bottom of my previous reply.
Back to top
View user's profile Send private message
neo81
Smarty Rookie


Joined: 06 Sep 2016
Posts: 6

PostPosted: Fri Sep 09, 2016 12:08 pm    Post subject: Reply with quote

I mean Smarty documentation.

This page:
http://www.smarty.net/docsv2/en/installing.smarty.extended.tpl
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1646

PostPosted: Fri Sep 09, 2016 4:15 pm    Post subject: Reply with quote

That documentation was written for Smarty 2, which was written for PHP4. (Which means, it's old as mammoth's dump.)
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
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