-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
overwrite bake templates #384
Comments
I done the same thing to overwrite the layout and that works, but the bake templates don't... |
Using plugin templates to override bake templates requires to use themes, and theme templates have a higher priority than application templates, hence you cannot override them. One option would be to copy all files from Another option would be to bake templates individually and use aliases, eg create |
Normally you want to override a plugins templates like cakeDC, BootstrapUI,... you can copy them to the templates folder under templates/plugin/vendorname/ then it will use the files from that folder. Only the way Bake implements it, it will not use the overriden templates, but it will use the template from the plugin itself. Yes, you can create a new plugin and place the templates there and then use the other plugin/theme. But why does bake not use the correct template file like the regular template system.... |
As I said, bake templates are provided by plugins using CakePHP's theme functionality, and that's simply how themes work, they override the application/plugin level templates, which will in turn become fallbacks. I guess it should be possible to add support for special application level overrides that win specifically over bake themes, you may want to create an issue over in the Bake repo. |
It would appear you not understand the problem with bake... |
its not application level, its about override a plugins template, hence put the template in templates/plugin/BootstrapUI. But you are right the problem is with the bake plugin... |
I understand what you're trying to override, when I'm saying "application level override" then I don't mean to override an application template, but simply that the override for the BootstrapUI plugin/theme template is defined in the application level templates. Unless I'm misunderstanding what you're asking for, I'm very much aware of what the "problem" in bake is. I don't want to sound like a broken record, but it's that theme paths will win over everything else. Go open protected function _paths(?string $plugin = null, bool $cached = true): array
{
$paths = parent::_paths($plugin, false);
foreach ($paths as &$path) {
// Append 'bake' to all directories that aren't the application override directory.
if (strpos($path, 'plugin' . DS . 'Bake') === false) {
$path .= static::BAKE_TEMPLATE_FOLDER . DS;
}
}
// Prepend application level override paths for current bake theme.
if (!empty($this->theme)) {
$themePlugin = \Cake\Utility\Inflector::camelize($this->theme);
$themeOverridePaths = [];
$templatePaths = \Cake\Core\App::path(static::NAME_TEMPLATE);
foreach ($templatePaths as $templatePath) {
$themeOverridePaths[] = $templatePath
. static::PLUGIN_TEMPLATE_FOLDER
. DIRECTORY_SEPARATOR
. $themePlugin
. DIRECTORY_SEPARATOR
. static::BAKE_TEMPLATE_FOLDER
. DIRECTORY_SEPARATOR;
}
array_unshift($paths, ...$themeOverridePaths);
}
return $paths;
} and then try baking again with
I'm somewhat confident that you'll see that what you're trying to do will suddenly work. |
I have copied and adjusted the files from BootstrapUI/bake/Template to templates/plugin/BootstrapUI/bake/Template/index.twig and adjusted them
But it does not seem to work.
The text was updated successfully, but these errors were encountered: