PDA

View Full Version : Installing Smarty Templates Engine


AngelDrago
20th June 2006, 18:39
Hi everyone, hallo till und falko wie gets euch... i have searched for some documentation on how to install the Smarty Template System... because i'm getting some error messages like this one...

Warning: main(/ispconfig/php/Smarty/Smarty.class.php): failed to open stream: No such file or directory in /var/www/web1/web/myapp/index.php on line 4

Fatal error: main(): Failed opening required '/ispconfig/php/Smarty/Smarty.class.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/web1/web/myapp/index.php on line 4

here is the link for there setup... http://smarty.php.net/quick_start.php
Thank you,
AngelDrago

falko
21st June 2006, 01:52
Does /ispconfig/php/Smarty/Smarty.class.php exist? Where do you put Smarty.class.php?

AngelDrago
21st June 2006, 04:42
in here /ispconfig/php/Smarty/ here is the link http://www.ultimateresources.com/myapp/index.php

Thank you,
AngelDrago

falko
21st June 2006, 18:18
What's the output of ls -la /ispconfig/php/Smarty
ls -la /ispconfig/php
ls -la /ispconfig?

AngelDrago
22nd June 2006, 17:41
know that is wired...

here is the output...

argo:~# ls -la /ispconfig/php/Smarty
ls: /ispconfig/php/Smarty: No such file or directory

argo:~# ls -la /ispconfig/php
ls: /ispconfig/php: No such file or directory

argo:~# ls -la /ispconfig
ls: /ispconfig: No such file or directory

Strange i know that the directories are there...

falko
23rd June 2006, 00:28
Did you run these commands
ls -la /ispconfig/php/Smarty
ls -la /ispconfig/php
ls -la /ispconfig
as root?

AngelDrago
23rd June 2006, 05:06
yes i have...see above...

falko
24th June 2006, 13:25
Then /ispconfig/php/Smarty/Smarty.class.php doesn't exist. Create it and try again.

Dimitriy
26th June 2006, 04:38
I have worked with Smarty before and I strongly suggest not doing it that way.

Instead implement smarty into each website as just as a php engine. Dont bother making it global otherwise you will run into issues of customization and so on. I enjoy having each application be seperate on its own space. While it sounds dumb and unclean programming for a person who single-handedly manages several sites, I find it easier both for me and my clients.

Just define the smarty dir like so (assume the path of the acutal public html is /home/www/web1/web/)

/home/www/web1/web/backend/includes/baseincludes.php
<?php

define('SMARTY_DIR', '/home/www/web1/smarty/libs/');


// put full path to Smarty.class.php
require(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = 'backend/templates';
$smarty->compile_dir = 'backend/templates_c';
$smarty->cache_dir = 'backend/cache';
$smarty->config_dir = 'backend/configs';

?>

Note the backend folder is RELATIVE TO THE CALLER FILE! The backend folder is not located in /libs/ of the smarty folder. If index.php calls for baseincludes.php all relative paths defined in baseincludes.php are relative to the caller file in this case index.php NOT baseincludes.php.

So basically Index.php goes up a level to fetch the libs files and then goes back to the location of index.php and fetches the info from /backend/x.

I know its a little rant but hope it helps.