如何自定义 yii2 主题 [英] How can I customize yii2 theme

查看:35
本文介绍了如何自定义 yii2 主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在尝试 Yii2.现在我已经创建了一个 yii2 基本应用程序.接下来我想做的是改变主题.我有一个 HTML 文件,我想像那个 HTML 一样更改这个应用程序主题.我已经经历了 yii2 主题化 但它不是我想要什么我想将该 HTML 的所有 css、js、图像、字体添加到我的项目中.我怎么能在 yii2 中做到这一点,请有人帮助我.

Im just trying Yii2. Now I have created a yii2 basic appication. Next what I want to do is change the theme. I have an HTML file I want to change this appications theme as like that HTML. I have gone through yii2 theming But Its not what i want I want to add all css,js,images,font of that HTML to my project. How can I do this in yii2 Plz somebody help me.

推荐答案

你必须像 yii1 一样简单地在 yii2 中做以下事情:-

Hi you have to do following things for theming in yii2 as simple as yii1 :-

  1. 首先打开 web.php 进入 yii2 应用的 config 目录,
  2. 然后在组件数组中传递视图数组,如:

  1. first of all open web.php into config directory of yii2 application,
  2. then in component array pass view array like:

    'view' => [
              'theme' => [
                 'pathMap' => [ 
                    '@app/views' => [ 
                        '@webroot/themes/demo/views',

                     ]
                 ],
               ],
            ] // here demo is your folder name

现在将文件夹名称创建为主题"到 web 目录中.

now create the folder name as "themes" into web directory.

在这个主题文件夹中复制你的 html 文件夹,如(演示),其中包含所有 css、js 等文件.在此文件夹中,将视图文件夹创建为 yii,其中包含 main.php 和其他布局(如果需要).

In this themes folder copy your html folder like(demo) which contains all css, js etc. files. in this folder create views folder as yii which contains main.php and others layouts if needed.

通过相应的索引文件覆盖视图中的 index.php通过适当更改文件路径.创建相应的视图和您的 html 文件的操作.在 yii2 中我们可以将我们的 css 和 js 定义到 Appasset.php 中.

override index.php in views by your corresponding index file by appropriate changes into paths of files. create corresponding views and actions for your html files. in yii2 we can define our css and js into Appasset.php .

这篇关于如何自定义 yii2 主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆