0

Is there a way of including a slot from generator.yml in Symfony? I would like to add a piece of HTML code only within some backend modules, and slots is the best idea I can come up with.

If not with generator.yml, how can I achieve this?

Thanks!

elitalon
  • 9,191
  • 10
  • 50
  • 86
  • What exactly (and where!) do you want to add? AFAIK Symfony allows to insert code in number of ways :) – Konstantin Jun 17 '11 at 15:15
  • @Konstantin Mikhaylov I want to add a div with a submenu under the main menu only in certain modules. The where (and how!) is exactly my question – elitalon Jun 17 '11 at 19:21

1 Answers1

1

Probably the easiest way to achieve this is to override the generated templates.

The admin generator generates templates based on generator.yml. You can view these generated templates in /cache/<app>/<env>/modules/<module>/templates.

If you view the files in this folder, you can just override them in the templates folder of your own module (not in the cache folder!). Just copy one of the files from the cache folder to the template folder of your module and start editing.

Grad van Horck
  • 4,488
  • 1
  • 21
  • 22
  • I thought about this, but I'd had to copy a lot of code just to add a really simple slot. I finally ended with a `switch` in `layout.php` using the request route to know when to output the HTML code I need – elitalon Jun 17 '11 at 13:41
  • 1
    You can also call the `slot()` function in one of the templates. (For example in the `_assets.php` partial: that one is included in all views that the generator generates). If calling `slot()` directly is too much code, you can also include your own `menu` partial, which does the `slot()`. – Grad van Horck Jun 17 '11 at 20:05