Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-03 19:35:42 11月12日 Update

Editor to share with you how the configuration file of PHP template engine Smarty is used in template variables, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

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.

Steps to use:

1. Use $tpl- > configs_dir= "directory" / / to specify the directory where the configuration files are stored.

2. Load the f configuration file in the template. If there is a region, you can use section= "region" to specify the region.

The purpose of setting the region is to call the profile variables of different regions for different files.

The region is specified through "[region name]" in the configuration file, and other variables that do not specify the area are common variables, that is, every page can be used.

3. Create a configuration file in the specified directory.

The following is demonstrated by an example: the main file index.php calls the template file index.tpl and sets the configuration file variables in index.tpl (independent of the PHP program)

Init.inc.php Smart template engine initialization file

Index.php

The index.tpl configuration variable can be used in two ways:

I.

II.

The display of configuration files in template variables using aaaa region variables:

/ configs/view.conf configuration file

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

The execution result, as shown in the figure:

The above is all the content of the article "how to use the configuration file of PHP template engine Smarty in template variables". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: File configuration template variable region directory website engine article different content instance program page not much function front end name appearance most Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL OPPO Reno Microsoft Docker