Sunday, November 7, 2010

Simple-Smarty! Installation

Quick install
-------------
Pre-requisite:
1. XAMPP installed in c:\xampp
=========
Steps:
--------
1. download smarty.zip
2. unzip as c:\smarty
3. add path "include_path=c:\smarty\libs" in c:\xampp\php.ini
4. create folders:
    (a) c:\smarty\templates_c (for templates compile)
    (b) c:\smarty\cache (for templates cache)
    (c) c:\xampp\htdocs\smarty\templates (for templates)
    (d) c:\xampp\htdocs\smarty\config (for smarty configuration)
5. Save as c:\smarty\libs\smarty_connect.php

<?php



 



// load Smarty library



require('Smarty.class.php');



 



class smarty_connect extends Smarty 



{



   function smarty_connect()



   {



        // Class Constructor. 



        // These automatically get set with each new instance.



 



        $this->Smarty();



 



        $this->template_dir = 'c:/xampp/htdocs/smarty/templates';



        $this->config_dir = 'c:/xampp/htdocs/smarty/config';



        $this->compile_dir = 'c:/smarty/templates_c';



        $this->cache_dir = 'c:/smarty/cache';



 



        $this->assign('app_name', 'Intranet');



   }



}



?>




6. Testing installation:

    (a) Save as 'c:\xampp\htdocs\smarty\templates\test.tpl':






<html>



<body>



<p>{$msg} </p>



</body>



</html>        





    (b) Save as 'c:\xampp\htdocs\test.php':





<?php



require("smarty_connect.php");



$smarty = new smarty_connect;



$smarty->assign("msg","Hello Smarty!");



$smarty->display("test.tpl");



?>





7. Run, 'http://localhost/test.php' z


    smarty-1