Thinkphp Framework (with existing templates and TP framework)

Source: Internet
Author: User

A basic introduction to the thinkphp framework

Directories created after the first visit

Four forms of routing

Create an app (in the first index.php)

Self-matching required files in controller

Calling the template for the view view

Note: The view names in the controller and view are consistent, $this->display (), and can be called directly;

Set the first page of the login site

The written display to the user's static page code input, you can access

(This machine's login address: Localhost/xampp/shop/index.php/home/index/index)

Access to the interface

Just have simple HTML code, and will not show the effect of CSS and JS. Because we're not setting up these code stores.

Then you start to enable CSS and JS

First, set up a new public folder under the Shop folder

Then open the new folder that contains the JS and CSS that decorate the HTML code.

New success, save the required code and pictures into it.

However, the only way to write code can not show the effect of Oh, pay attention to the HTML page to add CSS and JS links. This is the code:

<link href= "/xampp/shop/public/css/style.css" rel= "stylesheet" type= "Text/css"/>

In particular, pay attention to this code path problem, especially important!!!

To use an absolute path instead of a relative path, the browser will not show up. (The absolute path here is not the absolute path we usually call it)

So the effect of CSS can be out, but the picture is still not loaded out.

This effect occurs when you browse a Web page

Picture introduction:

So the picture has to be written in this way right his path


This actually just opens the part of the picture, because there are many pictures are stored in CSS style, so we also need to change the CSS style all over.

But please note!!!

The path to the CSS is relative to the path and not to the previous absolute path

Background:url (.. /images/inputbg.gif)

Similarly, other templates can be obtained in this way.

But such a one to change the IMG\CSS path is extremely troublesome, but also not conducive to later maintenance, so we need to set a constant.

In the index.php portal file, set one of his constants:

Then go to the static page to modify the corresponding CSS path

then modify the corresponding IMG path

The existing template is combined with the TP framework.

Specific implementation steps:

1. Copy template file to view specified directory

2. Copy the css\js\img static resource file to the system specified directory

3. Set the path of the static resource (css\js\img) file to "constant" information (set at index portal file)

4. In the template file through the constant introduction of static resources (css\js\img) file, path relative to the portal file settings

It is best to set absolute address (relative to the absolute address of the Working site Virtual host directory)

For later maintenance templates, the directory address is accessed by constant setting of the static resource file

The 5.css file itself is set by the picture, its path relative to the CSS file itself

Subsequent 1, 4 repeat implementation can be

Thinkphp Framework (with existing templates and TP framework)

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