tp5——实践前台模板引入

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/iheyu/article/details/86767031
1.把tp5拷贝到: 
	D:\phpStudy\WWW\lianxi
	
	2.在controller 控制器下 复制index.php文件内容到新建Cate.php  内容修改为:
	<?php
	namespace app\index\controller;
	use think\Controller; // 要继承这个类
	class Cate extends Controller
	{
    	public function index() // 就是加载index的模板文件
    	{
        return $this->fetch('Cate'); // 加载模板就是$this指向fetch这种方法,fetch()括号中限定模板名称
    	}
}
 
	3.在controller 控制器下 复制cate.php文件内容到新建Article.php 内容修改为:
 
	把 class Index extends Controller  修改为:class Article extends Controller
	把 return $this->fetch();          修改为:return $this->fetch(Article);  
	4. D:\phpStudy\WWW\lianxi\application\index
	下新建 view文件夹,在view文件夹下、新建index、cate、article文件夹
	D:\phpStudy\WWW\lianxi\application\index\view
	
	5.把‘前端的index.htm 文件复制到:’
	D:\phpStudy\WWW\lianxi\application\index\view\index
	修改index文件内容格式(如果隐藏后缀在则在当前页面点击查看->选项->在查看页面下->把隐藏已知文件类型扩展名对号去掉->点击确定 )
	http://www.iheyu.com/lianxi/public/index.php/index/index/index(没样式)
	6.把‘前端的list.htm 和article 文件复制到:’
	D:\phpStudy\WWW\lianxi\application\index\view
	修改list.htm 为cate.html和article 文件内容格式
	http://www.iheyu.com/lianxi/public/index.php/index/article/index(没有样式)

*****************************************************************************************
	模板文件不存在:C:\phpStudy\PHPTutorial\WWW\wanzheng\public/../application/index\view\index\index.html (bug)
	1.可能是view 下的 index.htm的格式不对! 
	2.我把view(视图)写成了vice!!!
*****************************************************************************************
***样式调整***
	7.在application下改config.php影响所有模块
	D:\phpStudy\WWW\lianxi\application\config.php
	如果想让config.php只对index起作用,就把config.php复制到:
	D:\phpStudy\WWW\lianxi\application\index 下
	只写你要配置的内容就可以了,修改内容:
	<?php
	return [
   	 'view_replace_str'  =>  [
       	 '__PUBLIC__'=>'/public/',
       	 '__ROOT__' => '/',
   	 ],
 	];
    8.定义常量在:
	D:\phpStudy\WWW\lianxi\public\index.php
	// 定义应用目录
	define('APP_PATH', __DIR__ . '/../application/');
	define('SITE_URL','http://www.iheyu.com/lianxi'); //定义常量,SITE_URL指向站点根路径
	9.创建前后台静态文件夹:
	D:\phpStudy\WWW\lianxi\public\static
	下创建 index文件夹(前台)
	下创建 admin文件夹(后台)
	
	
	10.修改路径在:
	D:\phpStudy\WWW\lianxi\application\index\config.php
	修改内容:<?php
			return [
    			'view_replace_str'  =>  [
       			 '__PUBLIC__'=>SITE_URL.'/public/static/index',
    			  ],
 			];
		
	11.创建前台静态文件夹在:
	D:\phpStudy\WWW\lianxi\public\static\index
	把前端的"images"(图片)和"style"(样式)拷贝过来
	12.引入CSS把插入到:
	D:\phpStudy\WWW\lianxi\application\index\view\index\index.html
	
	替换里面的内容:
	修改内容一:
	./style
	全部替换为
	__PUBLIC__/style/
	修改内容二:
	./images
	全部替换为
	__PUBLIC__/images/
	样式和图片都加载过来了!
	http://www.iheyu.com/lianxi/public/index.php
	13.用同样方法修改cate(列表)下的样式和图片:
	D:\phpStudy\WWW\lianxi\application\index\view\cate\cate.html
	修改方法同上
	http://www.iheyu.com/lianxi/public/index.php/index/cate/index
	14,用同样方法修改article(文章)下的样式和图片:
	D:\phpStudy\WWW\lianxi\application\index\view\article\article.html
	修改方法同上
	http://www.iheyu.com/lianxi/public/index.php/index/article/index

猜你喜欢

转载自blog.csdn.net/iheyu/article/details/86767031
今日推荐