zoukankan      html  css  js  c++  java
  • Thinkphp5笔记四:设置模板路径

    默认的模板路径在模块/view文件里面。如果你觉得这样不太方便管理,想要把他设置Template目录下,可以这样做。

    模板参数 ,能够影响的它参数,是当前模块下config.php template->view_path参数。

    实际操作

    一、配置共享参数

    在apps/config.php设置一些参数,方便在Index或Admin模块下config.php调用。

    apps/config.php,增加一些参数。

    'template'               => [// 模板路径
            'view_path'    => 'template/',     // 就是这里
    /**
         * 前台文件配置
         * Author: MR.zhou
         * */
        'index' => [
            // 模快名称
            'model_name' =>'index',
            // 默认模板文件名称
            'default_template' => 'default',       // 这里可以切换模块下的默认模板名称
        ],
        /**
         * 后台文件配置
         * Author: MR.zhou
         * */
        'admin'=>[
            // 模快名称
            'model_name' =>'admin',
            // 默认模板文件名称
            'default_template' =>'default',        // 这里可以切换模块下的默认模板名称
    ],

    二、设置模板参数

    index/config.php

      'template'               => [
        // 模板路径
        'view_path'    => config('template.view_path').config('index.model_name').'/'.config('index.default_template').'/',
    ],

    admin/config.php

    <?php
    //配置文件
    return [
        // 模板配置
        'template'               => [
            // 模板路径
            'view_path'    => config('template.view_path').config('admin.model_name').'/'.config('index.default_template').'/',
        ],
    ];

    扩展:

    1.模板后缀view_suffix,它的影响

    http://localhost/thinkphp/index/news/index/id/1212
    http://localhost/thinkphp/index/news/index/id/1212.html

  • 相关阅读:
    宽带上网路由器设置
    ssh 与 irc
    Centos7 wifi
    linux无法挂载u盘
    virtualbox之usb设备的分配
    5G工程师必备!5G协议清单大全
    SSB的时频资源怎么确定的?UE那边怎么检测呢?
    link
    C++有用link
    C++学习路线转载
  • 原文地址:https://www.cnblogs.com/wesky/p/6815241.html
Copyright © 2011-2022 走看看