When I currently use ./cake.bat bake template Genres
or ./cake.bat bake template Genres --prefix admin
, then the templates are used from these locations:
cakephp\bake\src\Template\Bake\Template\view.twig
cakephp\bake\src\Template\Bake\Template\index.twig
cakephp\bake\src\Template\Bake\Template\add.twig
cakephp\bake\src\Template\Bake\Template\edit.twig
I want to different versions of all these templates when I bake with the admin prefix. I tried creating a Bake Theme.
- I ran
./cake.bat bake plugin AdminTheme
- Then I placed the desired template files in
plugins/AdminTheme/templates/Bake/Template/
. - Ran
./cake.bat bake template Genres --theme AdminTheme
- Got
Error: "AdminTheme" is not a valid value for --theme. Please use one of "Bake, Migrations, WyriHaximus/TwigView"
Prefixes won't affect the template source, the path is pretty much hardcoded in
\Bake\Shell\Task\TemplateTask::getContent()
. One way to uses different templates is to bake each action separately, and use theaction
argument, and optionally thealias
argument to use the default name for the output, something along the lines of this:That would use the
Template/admin_index.ctp|twig
file, and write toTemplate/Admin/Genres/index.ctp
.As for your bake theme, the template folder structure in your theme plugin has to be:
not
Also make sure that your plugin is actually being loaded, ie check that
$this->addPlugin('AdminTheme');
exists in yourApplication
class'bootstrap()
method, or for earlier versionsPlugin::load('AdminTheme');
in yourconfig/bootstrap.php
file.See also Bake Cookbook > Extending Bake > Creating a Bake Theme