如何在 gii 中使用自定义模板(使用 Yii 2) [英] How to use custom templates in gii (using Yii 2)

查看:32
本文介绍了如何在 gii 中使用自定义模板(使用 Yii 2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法来为 Yii 2 使用自定义 Gii 模板,但查看 文档中缺少文档,我认为这是不可能的吗?还是我遗漏了什么?

I'm trying to find a way to use custom Gii templates for Yii 2, but looking at the missing documentation in the docs, I assume it's not possible yet? Or am I missing something?

推荐答案

Copy ie.从 gii/generators/crud/templates 到您的应用程序 app/templates/mycrud 的 crud 生成器模板.

Copy ie. the crud generator templates from gii/generators/crud/templates to your application app/templates/mycrud.

然后在您的配置中定义模板:

Then define the templates in your config:

$config['modules']['gii'] = [
    'class'      => 'yii\gii\Module',
    'generators' => [
        'crud'   => [
            'class'     => 'yii\gii\generators\crud\Generator',
            'templates' => ['mycrud' => '@app/templates/mycrud']
        ]
    ]
];

在文档完成之前,您还可以查看我的Gii 扩展如何创建自定义生成器和模板.

Until the documentation is finished you may also have a look at my Gii extension how to create a custom generator and templates.

这篇关于如何在 gii 中使用自定义模板(使用 Yii 2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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