Hi, Bundle best practices for templates : -------------------------------------------------
So we are looking at making use of DoctrineUserBundle, but feel like there is a bit of work to do in order to make the default controller and templates. First up by copying the default templates over into my Application dir, I can overload templates. However for this to be useful, it would be a good idea to separate extends from the rest. For example: http://github.com/knplabs/DoctrineUserBundle/blob/master/Resources/views/Session/new.php Here it would be good to to have one template that does the extends and another one that contains just the form. Potentially we could also make use of twig macro's here so that the template with the extends doesnt need to use include? Of course this requires migrating to twig, which I guess is the best practice we want to use for Bundles anyway. Also we want to take great care in defining some best practices for the HTML markup too. But especially for forms we should try to use the form API to the "max". Aka not render widgets, but render formgroups, because this then goes through the TwigBundle, which allows easily replacing of how things should be listed (for example using div's , like in the above example, or lists or sticking with the default table approach). Injecting custom variables into a 3rd party Bundle: ------------------------------------------------------------------- Now the bigger issue is that how can I get some custom variables into my layout. For example to display the menu header. Now one approach would be to essentially make an instance of the Bundle controller, for example DoctrineUserBundle\SessionController, inside an application Controller. Then I could with the above tools simply make the layout do nothing, so that I just get the form HTML. Then I can then render this HTML with some custom logic into the actual layout of my application. This however means that for every method I want to expose in a 3rd party Bundle, I have to write a wrapper method just so that I can inject a few things into the layout. Now Maybe there should be an event to hook into when a Controller loads a template. My application could then connect to this event to do some processing to generate various variables necessary inside my applications layout template. regards, Lukas Kahwe Smith [email protected] -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
