View previous topic :: View next topic |
Author |
Message |
phpbird Smarty Rookie
Joined: 09 Oct 2003 Posts: 5
|
Posted: Thu Oct 09, 2003 7:50 am Post subject: a question,please help me... |
|
|
i want to use smarty,and i want to use this to all of my web site ,no one single module.so i want to define one templates dir and others dirs.
i add code below at the top of
Smarty.class.php
$base_dir='/home/smartctl/';
if (!file_exists($base_dir."templates"))
mkdir($base_dir."templates",0777);
if (!file_exists($base_dir."templates_c"))
mkdir($base_dir."templates_c",0777);
if (!file_exists($base_dir."configs"))
mkdir($base_dir."configs",0777);
and modify
var $template_dir = '/home/savedata/templates';
var $compile_dir = '/home/savedata/templates_c';
var $config_dir = '/home/savedata/configs';
like this
var $template_dir = $base_dir.'templates';
var $compile_dir = $base_dir.'templates_c';
var $config_dir = $base_dir.'configs';
but ,when the php of website upgrade,the script doesn't work!
the message is
Parse error: parse error in /home/data/fu/smarty/libs/Smarty.class.php on line 92
help me ..... |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Oct 09, 2003 8:23 am Post subject: |
|
|
read http://smarty.php.net/manual/en/installing.smarty.basic.php
you SHOULD NOT EDIT any of the smarty-files.
you can configure $smarty->template_dir et. al. after you got your instance of $smarty with "new".
(btw: only constant expressions are allowed after "var")
[edit: grmpf, pasted wrong link. corrected] |
|
Back to top |
|
phpbird Smarty Rookie
Joined: 09 Oct 2003 Posts: 5
|
Posted: Thu Oct 09, 2003 8:30 am Post subject: |
|
|
why can't modify the smarty-files?
i modify the file just want to use it more easy...
now how can i modify the default dirs like what i want? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Oct 09, 2003 8:38 am Post subject: |
|
|
phpbird wrote: | why can't modify the smarty-files? |
of course, you can, but you shouldn't. and if you do so without really knowing what you do, don't ask for help here.
Quote: | now how can i modify the default dirs like what i want? |
again: read http://smarty.php.net/manual/en/installing.smarty.basic.php |
|
Back to top |
|
phpbird Smarty Rookie
Joined: 09 Oct 2003 Posts: 5
|
Posted: Thu Oct 09, 2003 8:57 am Post subject: |
|
|
i success the test...
the reason is ...
<?php
/* None of these will work in PHP 4. */
class Cart
{
var $todays_date = date("Y-m-d");
var $name = $firstname;
var $owner = 'Fred ' . 'Jones';
var $items = array("VCR", "TV");
}
/* This is how it should be done. */
class Cart
{
var $todays_date;
var $name;
var $owner;
var $items;
function Cart()
{
$this->todays_date = date("Y-m-d");
$this->name = $GLOBALS['firstname'];
/* etc. . . */
}
}
?>
thank u~~ |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Oct 09, 2003 11:55 pm Post subject: |
|
|
phpbird wrote: | why can't modify the smarty-files?
i modify the file just want to use it more easy...
now how can i modify the default dirs like what i want? |
Perhaps the next page of the manual is even better for you since it has an example of sub-classing Smarty so that you can make customizations without touching the base Smarty files.
http://smarty.php.net/manual/en/installing.smarty.extended.php |
|
Back to top |
|
phpbird Smarty Rookie
Joined: 09 Oct 2003 Posts: 5
|
Posted: Fri Oct 10, 2003 1:16 am Post subject: |
|
|
boots wrote: | phpbird wrote: | why can't modify the smarty-files?
i modify the file just want to use it more easy...
now how can i modify the default dirs like what i want? |
Perhaps the next page of the manual is even better for you since it has an example of sub-classing Smarty so that you can make customizations without touching the base Smarty files.
http://smarty.php.net/manual/en/installing.smarty.extended.php |
ok.it's a good idea!thanks a lot. |
|
Back to top |
|
|