Example of how to use the PHP template engine Smarty configuration file in template variables

Source: Internet
Author: User
Tags php template
This article mainly introduces how to use the configuration file of the PHP template engine Smarty in the template variables, and analyzes the procedure and related skills of using the configuration file variables in the form of instances, for more information about how to use the configuration file of the PHP template engine Smarty in template variables, see the example in this article. We will share this with you for your reference. The details are as follows:

The role of the configuration file in the template is to define variables for the front-end design page, which mainly controls the appearance of the template and has nothing to do with the PHP program.

Procedure:

1. use $ tpl-> configs_dir = "directory" // specify the directory where the configuration file is stored;

2. use <{configs_load file = "configuration file"}> in the template to load the f configuration file. if there is a region, use section = "region" to specify the region.

The purpose of setting a region is to call the configuration file variables of different regions for different files.
In the configuration file, "[region name]" is used to specify the region. other variables without the specified region are common variables, that is, each page can be used.

3. create a configuration file under the specified directory.

The following example demonstrates how to use an example: index. php in the main file calls index. tpl in the template file and sets the configuration file variable in index. tpl (unrelated to the PHP program)

Init. inc. php Smart template engine initialization file

 This document describes how to use the configuration file of the PHP template engine Smarty in template variables. We will share this with you for your reference. The details are as follows:

The role of the configuration file in the template is to define variables for the front-end design page, which mainly controls the appearance of the template and has nothing to do with the PHP program.

Procedure:

1. use $ tpl-> configs_dir = "directory" // specify the directory where the configuration file is stored;

2. use <{configs_load file = "configuration file"}> in the template to load the f configuration file. if there is a region, use section = "region" to specify the region.

The purpose of setting a region is to call the configuration file variables of different regions for different files.
In the configuration file, "[region name]" is used to specify the region. other variables without the specified region are common variables, that is, each page can be used.

3. create a configuration file under the specified directory.

The following example demonstrates how to use an example: index. php in the main file calls index. tpl in the template file and sets the configuration file variable in index. tpl (unrelated to the PHP program)

Init. inc. php Smart template engine initialization file

___FCKpd___0

Index. php

  This document describes how to use the configuration file of the PHP template engine Smarty in template variables. We will share this with you for your reference. The details are as follows:

The role of the configuration file in the template is to define variables for the front-end design page, which mainly controls the appearance of the template and has nothing to do with the PHP program.

Procedure:

1. use $ tpl-> configs_dir = "directory" // specify the directory where the configuration file is stored;

2. use <{configs_load file = "configuration file"}> in the template to load the f configuration file. if there is a region, use section = "region" to specify the region.

The purpose of setting a region is to call the configuration file variables of different regions for different files.
In the configuration file, "[region name]" is used to specify the region. other variables without the specified region are common variables, that is, each page can be used.

3. create a configuration file under the specified directory.

The following example demonstrates how to use an example: index. php in the main file calls index. tpl in the template file and sets the configuration file variable in index. tpl (unrelated to the PHP program)

Init. inc. php Smart template engine initialization file

   This document describes how to use the configuration file of the PHP template engine Smarty in template variables. We will share this with you for your reference. The details are as follows:

The role of the configuration file in the template is to define variables for the front-end design page, which mainly controls the appearance of the template and has nothing to do with the PHP program.

Procedure:

1. use $ tpl-> configs_dir = "directory" // specify the directory where the configuration file is stored;

2. use <{configs_load file = "configuration file"}> in the template to load the f configuration file. if there is a region, use section = "region" to specify the region.

The purpose of setting a region is to call the configuration file variables of different regions for different files.
In the configuration file, "[region name]" is used to specify the region. other variables without the specified region are common variables, that is, each page can be used.

3. create a configuration file under the specified directory.

The following example demonstrates how to use an example: index. php in the main file calls index. tpl in the template file and sets the configuration file variable in index. tpl (unrelated to the PHP program)

Init. inc. php Smart template engine initialization file

___FCKpd___0

Index. php

___FCKpd___1

There are two ways to use index. tpl configuration variables:
1. <{# configuration variable #}>;
II. <{$ smart. config. configuration variable}>

<{Config_load file = "view. conf" section = "one"}>
    
    Use of configuration files in template variables    
    
    
Aaaa Aaaa Aaaa Aaaa
Aaaa Aaaa Aaaa Aaaa
Aaaa Aaaa Aaaa Aaaa
Display of region variables: <{# aa #}>
<{# Bb #}>
<{# Cc #}>

/Configs/view. conf configuration file

border=2tabw=600tabh=500bgcolor=yellowalign=center[one]colspan=4aa=one section[two]bb=two section[three]cc=three section

Execution result ,:

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.