【问题标题】:CakePHP use different template for bakeCakePHP 使用不同的模板进行烘焙
【发布时间】:2017-12-23 15:41:21
【问题描述】:

在 cakePHP 上,我可以创建自定义烘焙模板。有没有办法为某个特定操作选择替代模板?

假设我有这些文件:

/App/src/Template/Bake/Template/add.twig
/App/src/Template/Bake/Template/edit.twig
/App/src/Template/Bake/Template/view.twig
/App/src/Template/Bake/Template/index.twig
/App/src/Template/Bake/Template/index_alternative.twig

bin/cake bake Template Articles 使用此列表的前 4 个模板文件。我需要做什么才能使用 index_alternative 模板烘焙索引?有什么参数可以控制这个吗?种

bin/cake bake Template Categories index --use index_alternative

或者我是否必须为此创建自己的 BakeTasks 或主题?或者有什么办法?

【问题讨论】:

  • 什么是树枝文件?
  • @Antoniossss 使用Twig template engine 处理的模板文件。 Bake 最近切换到使用 Twig 作为新的默认设置。
  • 传递index_alternative而不是index怎么样? Template 任务 action 参数专门指要使用的模板。
  • 烘焙然后在index_alternative.ctp 中创建。但我想要一个index.ctp 文件
  • 啊IC。我有一段时间不吃蛋糕了

标签: cakephp cakephp-3.0


【解决方案1】:

cake bake template --help 声明用法是:

cake bake template [subcommand] [options] [<controller>] [<action>] [<alias>]

因此,要为某个操作选择一个备用模板,如您的示例中所示,您必须将 alias 指定为 index 并烘焙 index_alternative 操作,例如:

cake bake template Categories index_alternative index

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-13
    • 2020-08-25
    • 1970-01-01
    • 2016-01-28
    • 1970-01-01
    • 2013-02-06
    • 2019-07-18
    相关资源
    最近更新 更多