PHP Smarty template for website

Source: Internet
Author: User
Tags gz file smarty template

/****************************************************************************** * PHP Smarty Temp Late for Website * Description: * have been thinking of MVC in the way to add to PHP Web site, so better processing, relatively good * processing, so follow-up maintenance will be better. * 2017-3-12 Shenzhen Nanshan Ping Shan village Zengjianfeng ******************************************************* **********************/First, reference documents:1. Smarty Tutorial http://www.yiibai.com/smarty/    2. Smarty Template engine http://www.smarty.net/    3. Parsing JSON file with PHP http://stackoverflow.com/questions/4343596/parsing-json-file-with-phpSecond, Smarty Download:1. GZ File:https://github.com/smarty-php/smarty/archive/v3.1.30.tar.gz    2. Zip File:https://Github.com/smarty-php/smarty/archive/v3.1.30.zipThree, configuration:1. Use relative paths to join the current project;2. Using require_once ('<path to Smarty.class.php>'):        <?PHP//Note:smarty have a capital ' S 'Require_once ('<path to Smarty.class.php'); $smarty=NewSmarty (); ?>3. Template file suffix name: <file name>. TPL4. Note: {* Comments *}    5. Assignment variables: $smarty->assign ('name','Ned'); 6. Processing templates: $smarty->display ('INDEX.TPL'); 7. Open Debug mode: $smarty->debugging =true; 8. Inherit class Smarty, extended functionality:<?PHP//Load Smarty LibraryRequire'Smarty.class.php'); //The setup.php file is a good place to load//required Application library files, and you//can do. An example://require (' guestbook/guestbook.lib.php ');        classSmarty_guestbook extends Smarty {function __construct () {//Class Constructor. //these automatically get set with the each new instance.parent::__construct (); $ This->settemplatedir ('/web/www.example.com/guestbook/templates/'); $ This->setcompiledir ('/web/www.example.com/guestbook/templates_c/'); $ This->setconfigdir ('/web/www.example.com/guestbook/configs/'); $ This->setcachedir ('/web/www.example.com/guestbook/cache/'); $ This->caching =smarty::caching_lifetime_current; $ This->assign ('app_name','Guest Book'); }        }        ?>9. Inherit using:<?php require ('guestbook/setup.php'); $smarty=NewSmarty_guestbook (); $smarty->assign ('name','Ned'); $smarty->display ('INDEX.TPL'); ?>Ten. Parse the JSON file when the configuration file, put the data into the Smarty object, so it is well configured.

PHP Smarty template for website

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.