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

Extended setup question

 
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 -> Installation and Setup
View previous topic :: View next topic  
Author Message
Jong
Smarty n00b


Joined: 25 Sep 2003
Posts: 4

PostPosted: Sat Sep 27, 2003 1:39 am    Post subject: Extended setup question Reply with quote

I have read the basic installation and then theextended setup in the manual. From what I understood you could be a Smarty, and make your own extended class of Smarty, and have all your settings in one place. So that's what I did.

setup.php
Code:
define ("SMARTY_DIR" , "smarty/");
require (SMARTY_DIR."libs/Smarty.class.php");

class smarty_template extends Smarty {
    function smarty_template() {
        $this -> Smarty();
       
        $this -> template_dir =  "templates/";
        $this -> compile_dir =  SMARTY_DIR."compile/";
        $this -> config_dir =  SMARTY_DIR."configuration/";
        $this -> cache_dir =  SMARTY_DIR."cache/";
    }
}

require ("includes/setup.php");

$template = new smarty_template();
$template -> assign ("value" , "something");
$template -> display ("a_template.tpl");


Everything worked great until I started editing all my .tpl files. For example I changed the value names and renamed some of the .tpl files.
Then everything went crazy, and suddenly none of the files worked anymore. All I got was an error telling me "failed to open stream: No such file or directory bla bla bla"...
At first I thought I'd something wrong in a file, so I cross-checked everything and every file, but no everything was as it should be. Four hours later I gave up. Then it suddenly striked me, so I tried to change the extended setup back to

Code:
require ("smarty/libs/Smarty.class.php");

$template = new Smarty();

$template -> template_dir =  "templates/";
$template -> compile_dir =  "smarty/compile/";
$template -> config_dir =  "smarty/configuration/";
$template -> cache_dir =  "smarty/cache/";


and bling bling, all my files worked again.

Someone help me out and tell me how come? Have I misunderstood something about the extended setup?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Sep 28, 2003 12:10 am    Post subject: Reply with quote

Strange!

Try calling the parent constructor $this->Smarty(); after you setup your custom features. Does that work?
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Sep 28, 2003 6:57 am    Post subject: Reply with quote

@Jong: to me it seems the main difference between your two setup is: you use a relative SMARTY_DIR in the first one ("smarty/") and an absolute SMARTY_DIR in the second one (defined inside "smarty/libs/Smarty.class.php" ). that could be the cause why the seconde one works better for you.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Jong
Smarty n00b


Joined: 25 Sep 2003
Posts: 4

PostPosted: Sun Sep 28, 2003 4:45 pm    Post subject: Reply with quote

I will have a look at your tips.
Back to top
View user's profile Send private message
Jong
Smarty n00b


Joined: 25 Sep 2003
Posts: 4

PostPosted: Mon Oct 13, 2003 4:16 am    Post subject: Reply with quote

messju > you were right, thanks Wink Also since my webhost is running scripts in safe-mode I had to add $this -> use_sub_dirs = false;

My code looks like this now...

Code:
define ("SMARTY_DIR" , "/abc/def/ghi/smarty/libs/");

require_once (SMARTY_DIR."Smarty.class.php");

class smarty_template extends Smarty {

    function smarty_template() {

        $this -> Smarty();

        $this -> use_sub_dirs = false;

        $this -> template_dir =  str_replace ("def/ghi/" , "" , SMARTY_DIR)."templates/";
        $this -> compile_dir =  str_replace ("ghi/" , "" , SMARTY_DIR)."compile/";
        $this -> config_dir =  str_replace ("ghi/" , "" , SMARTY_DIR)."configuration/";
        $this -> cache_dir =  str_replace ("ghi/" , "" , SMARTY_DIR)."cache/";

    }

}


P.S. can anyone tell me why there's such a different between running with a non-cache and a cache regarding the loading time? Obvious you can't have a cache when safe-mode is on...
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 -> 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