[php]在codeigniter中如何利用css创建视图 [php]如何使用codeigniter简化页面 网站地址:http://callmewhy.sinaapp.com/index.php/test 后面加上/testcss是测试css表单的页面 : http://callmewhy.sinaapp.com/index.php/test /testcss 加上testhead是测试头
[php]在codeigniter中如何利用css创建视图
[php]如何使用codeigniter简化页面
网站地址:http://callmewhy.sinaapp.com/index.php/test
后面加上/testcss是测试css表单的页面:http://callmewhy.sinaapp.com/index.php/test/testcss
加上testhead是测试头文件的插入:http://callmewhy.sinaapp.com/index.php/test/testhead
下面是以上两个案例的脚本文件。
完整的项目下载
首先是控制器controller,文件名test.php(要在config.php中配置):
load->view('welcome_view'); } function testhead(){ //测试head页面的引入 $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); }}?>
第一个测试css引入的view视图,文件名test_css_view.php:
why's test page
相应的css文件,文件名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;}
第二个测试head嵌入的view视图,文件名test_head_view.php:
load->view('header_view');?>
第三个是head的文件,文件名head_view.php: