[PHP] How to Use CSS to create a view in codeigniter
[PHP] How to Use codeigniter to simplify pages
Address: http://callmewhy.sinaapp.com/index.php/test
Followed by/testcss is the page for testing CSS forms: http://callmewhy.sinaapp.com/index.php/test/testcss
Plus testhead is the insert of the test header file: http://callmewhy.sinaapp.com/index.php/test/testhead
The following is the script file for the above two cases.
Download complete project
The first is the controller. The file name is test. php (to be configured in config. php ):
<? Phpclass test extends ci_controller {function _ construct () {// inherits the constructor of the parent class. If no value is specified, the parent :__ construct ();} function index () is returned () {$ this-> load-> View ('Welcome _ view');} function testhead () {// test the introduction of the head page $ data ['mytitle'] = "A website monitoring tool"; $ data ['mytext'] = "test! Test! "; $ Data ['myrobots'] = 'noindex, nofollow'; $ data ['mywebtitle'] = 'web monitoring tool '; $ data ['base'] = $ this-> config-> item ('base _ url'); $ this-> load-> View ('test _ head_view ', $ data);} function testcss () {$ data ['mytitle'] = "A website monitoring tool"; $ data ['mytext'] = "test! Test! "; $ Data ['base'] = $ this-> config-> item ('base _ url '); $ data ['css '] = $ this-> config-> item ('test _ CSS'); $ this-> load-> View ('test _ css_view ', $ data) ;}}?>
First, test the view introduced by CSS. The file name is test_css_view.php:
Corresponding cssfile, file name test.css:
h1{margin : 5px;padding-left : 10px;padding-right : 10px;background : #ffffff;color : blue;width : 100%;font-size : 36px;}.test{margin : 5px;padding-left : 10px;padding-right : 10px;background : #ffffff;color : red;width : 100%;font-size : 36px;}
The second test is the view embedded in the head. The file name is test_head_view.php:
The third is the head file. The file name is head_view.php:
<title><?php echo $mywebtitle?></title><base href="<?php echo"$base";?>"/><meta name="robots"content="<?php echo $myrobots?>"><link rel="stylesheet" type="text/css" href="<?php echo"$base/$css";?>"/>