Installing Smarty Templates Engine

Discussion in 'Installation/Configuration' started by AngelDrago, Jun 20, 2006.

  1. AngelDrago

    AngelDrago Member

    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...
    Thank you,
  2. falko

    falko Super Moderator Howtoforge Staff

    Does /ispconfig/php/Smarty/Smarty.class.php exist? Where do you put Smarty.class.php?
  3. AngelDrago

    AngelDrago Member

  4. falko

    falko Super Moderator Howtoforge Staff

    What's the output of
    ls -la /ispconfig/php/Smarty
    ls -la /ispconfig/php
    ls -la /ispconfig
  5. AngelDrago

    AngelDrago Member

    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...
  6. falko

    falko Super Moderator Howtoforge Staff

    Did you run these commands
    ls -la /ispconfig/php/Smarty
    ls -la /ispconfig/php
    ls -la /ispconfig
    as root?
  7. AngelDrago

    AngelDrago Member

    yes i have...see above...
  8. falko

    falko Super Moderator Howtoforge Staff

    Then /ispconfig/php/Smarty/Smarty.class.php doesn't exist. Create it and try again.
  9. Dimitriy

    Dimitriy New Member

    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/)

    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.

Share This Page