[Label] [smarty] smarty usage experience

Source: Internet
Author: User

The smarty template engine can implement page caching to accelerate page access after initialization.

To some extent, the smarty template ensures that the Code on the template page is neat and tidy, avoiding the combination of HTML tags and PHP.

When maintaining the business logic code, we can only modify the script file of the business logic code;

When page modification and page reconstruction are generated, we can only modify the page file.

 

PHP is only responsible for business logic and Data

The smarty template displays the data to the page because HTML tags do not have any logical functions.

 

Suggestions for using the smarty template:

 

1. Do not assign variables to the smarty template. Instead, organize and classify the data according to relevance and use a one-dimensional correlated array assign.

In the TPL file, data is obtained and displayed through array access using the smarty template.

 

Example: an online web hotel reservation website with a reservation navigation bar on all pages, such:

 

Data in the navigation bar: Check in date, check out date, adults, children, nights, extrabed, package

The seven data items should be related to the reservation. They can be combined into an array, and then assign in the past and called in TPL.

Instead of distributing each data to the assign, it is inconvenient to manage and modify the data.

 

The room information to be displayed in step 1 can be stored as an independent array and then called in TPL by assign, for example:

 

 

[Label] [smarty] smarty usage experience

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.