Questions about introducing paths to thinkphp5.1 files

Source: Internet
Author: User
This article mainly introduces the thinkphp5.1 file introduction path problem, this article introduces to you very detailed, has certain reference value, needs the friend can refer to under

Thinkphp5.1 File Introduction

1. Introduction of other view files in the view file

File directories such as:

You need to implement the four HTML template files that are introduced into the public folder in Index.html, index.html introduces the following code:

{include file= "/public/_meta"} {include file= "/public/_header"} {include file= '/public/_menu '}<p> middle section fill in the page-specific content </p>{include file= "/public/_footer"}

In this way, it is possible to extract common, infrequently changed content, avoiding code redundancy.

2. A static file under the public file is introduced in the view file

File directories such as:

We need to introduce some static CSS, JS files in the index.html view template, these files are usually stored in the public directory, we now introduce these files in the way of relative paths, the index.html file introduces the following code:

<link rel= "stylesheet" type= "Text/css" href= "/... /static/hadmin/static/h-ui/css/h-ui.min.css "rel=" external nofollow "/><link rel=" stylesheet "type=" Text/css " Href= "/.. /static/hadmin/static/h-ui.admin/css/h-ui.admin.css "rel=" external nofollow "/><link rel=" stylesheet "type=" Text/css "href="/... /static/hadmin/lib/hui-iconfont/1.0.8/iconfont.css "rel=" external nofollow "/><link rel=" stylesheet "type=" Text/css "href="/... /static/hadmin/static/h-ui.admin/skin/default/skin.css "rel=" external nofollow "id=" Skin "/><link rel=" Stylesheet "type=" Text/css "href="/... /static/hadmin/static/h-ui.admin/css/style.css "rel=" external nofollow "/>

In my test project, the above code was introduced successfully. If the actual practice of the introduction of failure, do not worry, introduce a convenient way to debug: First, refresh your Web page, the second step, the right to view the Web page source code, the third step, copy the corresponding file introduction link, open in the new page; fourth, check where the browser actually recognizes the file path, Adjust the URL to the correct file path, that is, to correctly access the contents of the file, the fifth step, refer to the available file path to improve the existing path.

3. Define global variables and use them in the template file

To illustrate, tp5.1 changed the configuration variable name and changed it as follows:

' tpl_replace_string '   = [    ' __static__ '   = '/static ',  ],

Specific implementation steps:

1. Add the constants you need to define in config/template.php.

2, directly in the template can be used, as follows:

<link rel= "stylesheet" type= "Text/css" href= "__static__/hadmin/static/h-ui/css/h-ui.min.css" rel= "external Nofollow "/>

This path is set according to your actual project directory and can be changed by yourself.

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

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.