The initialization method for installing and using the smarty template engine in Linux-Linux Enterprise Application-Linux server application information. For more information, see the following. Install Smarty:
1. Download and decompress the package
2. Copy the libs folder to the/var/www/html directory.
3. Create a New Mysmarty folder in the/var/www/html directory.
4. Create Four folders named cache, templates, templates_c, and configs in the Mysmarty folder.
5. Set the templates and templates_c permissions to 777.
Test Smarty
1. Create test. php In the Mysmarty folder. The content is as follows:
CODE:
Include ("/var/www/html/libs/Smarty. class. php"); // contains the smarty class file
$ Smarty = new Smarty (); // create a smarty Instance Object $ smarty
$ Smarty-> template_dir = '/var/www/html/Mysmarty/templates ';
$ Smarty-> compile_dir = '/var/www/html/Mysmarty/templates_c ';
$ Smarty-> config_dir = '/var/www/html/Mysmarty/configs ';
$ Smarty-> cache_dir = '/var/www/html/Mysmarty/cache ';
$ Smarty-> caching = false;
$ Smarty-> left_delimiter = "<{";
$ Smarty-> right_delimiter = "}> ";
$ Smarty-> assign ("title", "test"); // replace template Variables
$ Smarty-> assign ("content", "bbbbbbbbbxxxxxxxbbbbbbbbbbbbbb ");
// Compile and display the index. tpl Template under./templates
$ Smarty-> display ("test. tpl ");//
?> |