Thinkphp ,__ public _ loading CSS, JS failed

Source: Internet
Author: User
Tags html header

Thinkphp was recently learned, but the process was certainly not a crash. after a day or two, I finally felt a little bit :):

I initialize the directory structure of my project:

------/Www/

----------/Www.myapp.com/

-------------------------/MyAdmin/<! -- Project background -->

/Thinkphp/<! -- TP folder -->

/Index. php <! -- Front-end portal file -->

/Admin. php <! -- Background portal file -->

/MyApp/<! -- Project front-end -->

The focus is on the configuration of MyApp. The principle of myamin is the same as that of MyApp.

I don't want to put the public folder in the root directory as on the official website. I want an application to be public, that is, for MyApp, my public path is like this:

/Www/www.myapp.com/myapp/public/

The configuration of/www/www.myapp.com/index.php is as follows:

 

View code

<? PHP // define ('app _ debug', true); define ('thank _ path ','. /thinkphp/'); define ('app _ path ','. /MyApp/'); define ('app _ name', 'myapp'); require (thank_path. 'thinkphp. PHP ');?>

 

 

The configuration of/www/www.myapp.com/myapp/index.php is as follows:

View code

<? PHP // define the project name and path define ('app _ name', 'myapp'); define ('app _ path ','. /'); // load the framework entry file require (".. /thinkphp. PHP ");

 

/Www/www.myapp.com/myapp/config/config.php configuration is as follows:

View code

<? PHP // array ('_ Public _' => '/myapp' must be'/myapp' // If array ('_ Public __ '=> 'myapp' // use the response array ('db _ type' => 'myapp ', 'url _ model' => 1, 'db _ host' => 'localhost', 'db _ name' => 'myapp ', 'db _ user' => 'root', 'db _ pwd' => '', 'db _ port' => '123 ', 'db _ prefix' => 'ma _ ', 'url _ model' => 0, 'tmpl _ parse_string '=> array (' _ Public _ '=>'/myapp' ),);?>

Other

/Www/www.myapp.com/myapp/lib/action/index.class.php in the index () method, $ this-> display (); you can call the template...

For example, the index module template should be as follows:

/Www/www.myapp.com/myapp/tpl/index/index.html

/Www/www.myapp.com/myapp/tpl/index/header.html

/Www/www.myapp.com/myapp/tpl/index/footer.html

In the header, you can use the following statements to call JS and CSS:

View code

<link href="__PUBLIC__/Public/css/a.css"  rel="stylesheet" type="text/css" /><script src="__PUBLIC__/Public/js/a.js" type="text/javascript"></script><script src="__PUBLIC__/Public/js/b.js"  type="text/javascript" ></script>

Index.htmlimport header.html: <include file = "Header"/>

Other modules, such as add)

/Www/www.myapp.com/myapp/lib/action/add.class.php in the index () method, $ this-> display (); you can call the template...

For example, the index module template should be as follows:

/Www/www.myapp.com/myapp/tpl/add/index.html

The value is that you can use the index.html header.html: <include file = "index: Header">

 

 

This is almost the case. Linux seems to be case sensitive!

 

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.