SHOPNC Learning (a) tpl.php template driver

Source: Internet
Author: User
Tags php class php template

After the Controller method finishes processing the data, it calls Tpl::ouput () and Tpl::showpage () to separate the outgoing data and invoke the page template. So record the learning tpl.php class here.

Static variables in this class:

$instance: Storing instances of this class
$output _value: Store output data
$TPL _dir: Store Default template path (folder name)
$layout _file: Store Default layout Name

The party static method in this class:
GetInstance (): Checks whether the static variable $instance is an instance, and if not, instantiates a TPL class and assigns it to the $instance
Setdir ($dir): Sets the folder where the template file is located, that is, the value of the static variable $tpl_dir
SetLayout ($layout): Sets the default layout name, which is the value of the static variable%layout_file
Output ($output, $input = "): Stores the input data into the static variable $output_value, where the parameter $output is key, $input is the value
ShowPage ($page _name= ", $layout =", $time =2000): Find the corresponding template $page_name and layout files according to the settings, and include_once ()

And a function to turn on cache Templatecachestart (), turn off Cache Templatecacheend (), and display trace information on the page showtrace ()

The output () function is used primarily in the controller to export data, use the ShowPage () function to assemble the template file path, and then include and run the template file.

SHOPNC Learning (a) tpl.php template driver

Related Article

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.