About catalog Setup and rendering issues for TP templates

Source: Internet
Author: User

In the Site Directory/common/conf/config.php:

Modify the directory of the template (this time the view directory is invalid)

Original:/Site Directory/module directory/view directory/[Template theme/] Controller name/action name. suffix

Now:/template directory/module directory/[Template theme/] Controller name/action name. suffix

' View_path ' = './public/',


Specifies the view directory, which is the default

' Default_v_layer ' = ' View ',

Specify template theme (no theme if not specified)

' Default_theme ' = ' Red ',


Modify the TOC hierarchy with an underscore,

Original: New ControlName folder under View directory, ACTION.TPL file

' Tmpl_file_depr ' = ' _ ',

Now: New Controlname_action.tpl file under View directory


Specifies the template file suffix, which is HTML by default

' Tmpl_template_suffix ' = '. TPL ',


In the controller's method file:

Class Usercontroller extends Controller {

Public Function vv () {

$this->display (); Default Path

$this->assign (' abc ', ' new title '); Specifying variables and values

$this->theme (' Default ')->display (); Specify template Theme

$this->display (' age '); Specifying template files

$this->theme (' Blue ')->display (' [email protected]/salary/age '); location ①

Specify template themes, modules, controllers, template files

$this->display ('./template/public/user/index.html '); location ②

Specify absolute path to absolute template file

}

}

It should be stated that:

location ①: If you set the ' Tmpl_file_depr ' = ' _ ' In the configuration file,

Then this path is: Site Directory/admin/view directory/BLUE/USER_PERSON/SALARY/AGE.TPL

Location ②: When the path to the absolute template file exists and is correct, all other configuration about the template path is invalidated, whichever is the absolute path


When you use the T () method to get or set the template address:

T () returns the address of the current template:

When set, if you use ' tmpl_file_depr ' = ' _ ',

T (' [email protected] ') = ./site/Admin/view directory/RED/USER_AGE.TPL

T (' [email protected]/age ') = ./site/Admin/view directory/RED/SALARY_AGE.TPL

T (' [email protected]/salary/age ') = ./Site/admin/View catalog /PERSON/SALARY_AGE.TPL

Note the difference from the direct display () parameter:

Display (' [email protected] ') ./Site/admin/View catalog/red/user_age.tpl

Display (' [email protected]/age ') ./Site/admin/View catalog/red/user_salary/age.tpl

Display (' [email protected]/salary/age ') ./Site/admin/View catalog /red/USER_PERSON/SALARY/AGE.TPL


If you use $this->display (T ()), you can also render

At this time, you can no longer set the template theme, that is, $this->theme (' Default ')->display (T ()) When the Theme Settings section is considered invalid

The template theme now uses the settings in the configuration file

second, the path at this time has been converted to an absolute path, which is equivalent to the location ② use, as long as the path is correct




This article from "thinkphp Study notes" blog, declined reprint!

About catalog Setup and rendering issues for TP templates

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.