Thinkphp template path problems

Source: Internet
Author: User
Thinkphp is used for the first time in the thinkphp template path problem. The setting of the resource file path in the template has never been understood.
For example

My project uses groups 'admin' and 'content ', previously, in order to test the template display effect, a PageTestAction was simply written, and only one show method was used to display the template. in order to facilitate setting the default group, default model, and default method, the access address http: // localhost/XBlog (project name)/index. php is normal.

When I access the resource file through the normal path http: // localhost/XBlog/index. php/Content/PageTest/show, the resource file is invalid.

According to my understanding, '/public' ='/public' and '. /Public '= '. /Public ', and '. /'indicates the current directory, so '. /Public 'the relative address is relative to index. php. However, when '/Content/PageTest/Show' is added to the backend, isn't'/Content/PageTest/Show' also used as a path, does it change the current path? Isn't it a virtual path used to represent groups, modules, and methods?

Also, I found that if the relative address of the website root directory is I don't understand what is in the middle of a project name directory? ': It will be replaced with the current website address (excluding domain names)/index. php: it will be replaced with the URL address (excluding the domain name) of the current project. can a website contain multiple projects?
What is the relationship with/index. php?
Although there are multiple projects in the local WWW folder, isn't the formal deployment on the server like this? /XBlog (project name)/Public/Theme/default/css/bootstrap.min.css "will this write affect deployment?


Reply to discussion (solution)

You can view thinkphp Manual: 1. and/index. php are system constants.
In a single module tpl template, you can use relative paths to reference files.

You can view thinkphp Manual: 1. and/index. php are system constants.
In a single module tpl template, you can use relative paths to reference files.


You didn't say anything! Can you give me some answers to my questions? Didn't you find that ': it will be replaced with the current website address (excluding the domain name)/index. php: will it be replaced by the URL address (excluding domain names) of the current project? I just asked, okay?

Www/website root http: // localhost/
Www/index. php entry file http: // localhost/index. php
Www/app/Project Directory http: // localhost/app/
All files and directories in the www/app/... project

Www/website root http: // localhost/
Www/index. php entry file http: // localhost/index. php
Www/app/Project Directory http: // localhost/app/
All files and directories in the www/app/... project


But my project structure is not like this?

The entry file is also in the APP Directory. this is the directory structure automatically generated by thinkPHP.

Www/website root http: // localhost/
Www/index. php entry file http: // localhost/index. php
Www/app/Project Directory http: // localhost/app/
All files and directories in the www/app/... project


"First, create an App directory under the server or local Web directory, copy the ThinkPHP Directory of the downloaded ThinkPHP framework to the App directory, and create an index under the App directory. php file, which is the entry file for creating a project." This is the original thinkPHP manual.

First question:
/Content/PageTest/show does change the path, so the source address of the template must use the path relative to the root directory rather than the current address.
Second question:
/XBlog should be the project folder you created under the www Directory. The website root directory refers to the www folder rather than the project folder.
Third question:
/XBlog (project name)/Public/Theme/default/css/bootstrap.min.css may affect the deployment, because the content in the project folder is usually directly placed in the www folder during deployment, in this case, remove/XBlog (project name)

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.