0

My App is both using prefix Admin and having a plugin RubriquesManager.

In the plugin RubriquesManager I have 2 elements articles for each side (front side and admin side) :

  • /plugins/RubriquesManager/templates/element/articles.php displays articles for front side

  • /plugins/RubriquesManager/templates/Admin/element/articles.php displays articles for admin side (with buttons for article editing, deleting, ...)

In order to override in my app the front side element articles of plugin RubriquesManager I have created the file :

/templates/plugin/RubriquesManager/element/articles.php

The problem is that Cake is using this element both for overriding element articles for front side and also for admin side while I didn't create /templates/plugin/RubriquesManager/Admin/element/articles.php !...

I don't understand the point for Cake to act like that ? Is there a way to tell to Cake not to try to overide for admin side ?

Oliv
  • 236
  • 3
  • 12
  • Can't test it right now, but IIRC element lookup has a fallback order, first prefixed ones are looked up, then non-prefixed ones. I guess the point is to avoid unnecessary duplication, for example elements could easily be something that you'd want to share across all sorts of layouts and prefixes. So what you're seeing might actually be the expected behavior, unless maybe if you actually have an admin prefixed element in your plugin, and it is still being overridden by the non-prefixed app one. Not sure if that would be the correct/expected behavior. – ndm Jan 27 '23 at 19:59
  • @ndm I do have an admin prefixed element in my plugin (`/plugins/RubriquesManager/templates/Admin/element/articles.php`) and it is overridden by `/templates/plugin/RubriquesManager/element/articles.php` as I didn't create `/templates/plugin/RubriquesManager/Admin/element/articles.php`... Weird... – Oliv Jan 28 '23 at 08:38
  • 1
    Thinking about it, I guess that is the expected behavior currently, as app override templates are tested first and follow the same fallback order. So it's 1. app prefix-element, 2. app element, 3. plugin prefix-element, 4. plugin element. I can see how that might feel counter intuitive, and one might expect a different order, like 1. app prefix-element, 2. plugin prefix-element 3. app element, 4 plugin element. Not sure about the possible implications of such an order though. You may want to open an issue over at GitHub, and see what others think about it. – ndm Jan 28 '23 at 12:36

0 Answers0