thinkphp templates inherit and modify title

Source: Internet
Author: User

First, the template inherits:

Assumption: In the View folder

Public module

->base/header/top/footer 4 HTML files

The following base file uses include to introduce the other 3 files, where title uses the block tag, gives a name attribute, and can be used in different templates to redefine the title value .

Block tag, property is main can be, write different content in different template

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <Metaname= "Viewport"content= "Width=device-width, initial-scale=1.0">    <Metahttp-equiv= "X-ua-compatible"content= "Ie=edge">    <title><Blockname= "title">Title</Block></title></Head><Body>    <includefile= "Public/header" />    <includefile= "Public/top" />    <Blockname= "Main"></Block>    <includefile= "Public/footer" /></Body></HTML>
View Code

The->user module and the UserController.class.php control correspond to the

This is the file that inherits the base

{__nolayout__}<!--force not loading layout -<!--how templates are inherited -<Extendname= "Public/base" /><Blockname= "title">This is the title of the Select</Block><Blockname= "Main">    <Divstyle= "box-shadow:2px 2px 2px Red">This is the Select module</Div></Block> 
View Code

After executing the file, you can see that the inheritance succeeds and the title value is also modified

There is also a way to modify the corresponding title value is in the base file,<title>{$title}</title>, with a variable to replace , and then in the corresponding execution of the controller, assign the value to the variable

thinkphp templates inherit and modify title

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.