thinkphp template replacement with system constants and application examples tutorial, thinkphp example Tutorial _php tutorial

Source: Internet
Author: User

thinkphp template replacement and system constants and application examples tutorial, thinkphp example Tutorial


This paper describes the thinkphp template replacement and system constants and applications, is the basic knowledge of thinkphp project development, it is necessary to be firmly mastered. Specific as follows:

Default Template substitution rules:

.. /public: The common template directory that will be replaced with the current project is usually/project directory/tpl/default/public/
__PUBLIC__: The common directory that will be replaced with the current site is usually/public/
__tmpl__: The template directory that will be replaced with the project is usually/project directory/tpl/default/
__ROOT__: Will replace the address of the current website (excluding domain name)
__APP__: Will replace the URL address of the current project (excluding domain name)
__URL__: Will replace the URL address of the current module (excluding domain name)
__ACTION__: Will replace the current operation's URL address (without domain name)
__SELF__: Will replace the current page URL

You can also customize the substitution rule by configuring the value of Tmpl_parse_string in the project configuration file, such as:

tmpl_parse_string = = Array (   ' __public__ ' = '/common ',  //change the default __public__ substitution rule   ' __upload__ ' = '/ Public/uploads/',  //Add new upload path substitution rules)

Example:

File path:/home/tpl/default/user/index.html, the code is as follows:

__root__ represents the URL of the current Web site

__URL__ represents the URL address of the current module/index.php/user

.. /public Representative/aoli/tpl/default/public

__PUBLIC__ represents the project public file directory/public

__tmpl__ represents the template directory for the current project/aoli/tpl/default/

__APP__ represents the entry file address of the current project/index.php

__ACTION__ represents the current operating address/index.php/user/index

__self__ represents the current URL address/index.php/user/

__upload__

File path:/home/lib/action/useraction.class.php, the code is as follows:

<?php class Useraction extends Action {    function index () {      $this->display ();         }    function Add () {      dump ($_post);       }}? >

Access path: Http://localhost/index.php/User/index input content, click the Register button to jump to Http://localhost/index.php/User/add and execute the Add method under the User module, Outputs the submitted content.

It is hoped that this article is helpful to everyone's thinkphp program design.


thinkphp that system constant __app__, to change where to change

Can be redefined in the configuration file (config.php),
Tmpl_parse_string =>array (
' __app__ ' = ' New path ',
)
For details, refer to "7.4 Template replacement" in thinkphp Full development manual 3.0

thinkphp How to display the system constant name directly in the template file?

Using the original PHP output

Technical Support: Thesis area 9th

http://www.bkjia.com/PHPjc/868233.html www.bkjia.com true http://www.bkjia.com/PHPjc/868233.html techarticle thinkphp template replacement and system constants and application examples tutorial, thinkphp example Tutorial This article describes the thinkphp template replacement and system constants and applications, is thinkphp the basic knowledge of project development, ...

  • 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.