Re: [SMARTY] Directories
| From: | Ferdinand Beyer | Date: | Sun, 09 Feb 2003 11:15:53 +0000 |
| Subject: | Re: [SMARTY] Directories | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7605@lists.php.net to get a copy of this message | ||
On 9 Feb 2003 at 11:39, Felix wrote:
>
> Thanks for the rapid reply!
> i tried to define the paths:
> <?php
> define('SMARTY_DIR','http://www.domain.de/include/'
>);
Don't use the http://... URIs!!!
When speaking about absolute paths I meant absolute paths on the
server!
For example on Windows absolute paths are:
C:\WINDOWS\System or F:\WebRoot\Smarty\Smarty.class.php
On Unix/Linux absolute paths are
/user/fbeyer or /usr/local/lib
If you define SMARTY_DIR with http://www.domain.de/include/ PHP
establishes a HTTP connection to domain.de exactly as if you where
opening it with a web browser. Since Smarty.class.php defines a
PHP class but has no displaying logic, it will return an empty page
and your PHP script can't find the Smarty class definition.
Your absolute SMARTY_DIR is /www/htdocs/v033802/ (you are
using a Unix/Linux Server), as it can be seen by the PHP error
messages.
So please use
define('SMARTY_DIR', '/www/htdocs/v033802/');
> require(SMARTY_DIR.'Smarty.class.php');
With the correct SMARTY_DIR, this should work now. But since a
class definition should only be included once, it is good style to
include it using the require_once() statement. Furthermore you do
not need brackets with language constructs like require(), include()
or return:
require_once SMARTY_DIR . 'Smarty.class.php';
> $smarty = new Smarty;
>
> $smarty->template_dir = 'è
> Ë6¨KÔ;Dz¸Uhttp://www.domain.de/include/templates/';
> $smarty->compile_dir =
> 'http://www.domain.de/include/templates_c/';
> $smarty->config_dir =
> 'http://www.domain.de/include/configs/';
> $smarty->cache_dir =
> 'http://www.domain.de/include/cache/';
Here is the same problem: Do not use http URIs here!
I recommend you to use the SMARTY_DIR constant since you will
only have to update it once if your smarty directory changes:
$smarty = new Smarty();
$smarty->template_dir = SMARTY_DIR . 'templates';
$smarty->compile_dir = SMARTY_DIR . 'compile';
$smarty->config_dir = SMARTY_DIR . 'configs';
$smarty->cache_dir = SMARTY_DIR . 'cache';
$smarty->plugin_dir = array(SMARTY_DIR . 'plugins');
> $smarty = new Smarty;
Why do you re-create the Smarty object here?! You already have a
working Smarty object in $smarty, haven't you?
> $smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
>
> $smarty->assign("FirstName",array("John","Mary","James","Henry"));
>
> $smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
>
> $smarty->assign("Class",array(array("A","B","C","D"),
> array("E", "F", "G", "H"),
> array("I", "J", "K", "L"), array("M",
> "N", "O", "P")));
>
> $smarty->assign("contacts", array(array("phone" => "1",
> "fax" => "2", "cell" => "3"),
> array("phone" => "555-4444", "fax" =>
> "555-3333", "cell" => "760-1234")));
>
> $smarty->assign("option_values",
> array("NY","NE","KS","IA","OK","TX"));
> $smarty->assign("option_output", array("New
>
> York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
> $smarty->assign("option_selected", "NE");
>
>
> $smarty->display('http://www.domain.de/include/templates/index.tpl');
>
You can now access templates relative to your template_dir folder.
You mustn't use URIs!
Simply use
$smarty->display('index.tpl');
> Sorry for asking such kind of newbie questions but I'm just new to it!
> Thanks!
> Felix
--
Ferdinand Beyer
<fbeyer@clickhand.de>