Currently all backend modules generate quite a lot of duplicated code for:
Initializing view (based on BackendTemplateView)
Initializing module template/pageRenderer…
Initializing uri-builder with current request
Building top level sub menu for actions / adding buttons to docheader…
As all of these are related to the view helpers, Helmut proposed to add ViewHelpers for this functionality to the core, so we can get rid of all the controller code. I’d additionally propose a step-by-step tutorial on how to write backend modules to show the functionality and make it widely known.
New ModuleTemplate ViewHelpers in the core
- More convenience for developers
- Consistent look and fool throughout the backend is much easier to achieve
- Less code duplication
- Simple. Since it is Fluid, even non PHP programmers could customize the docheader of modules
- Clean separation of controller and view. Enabling different output without touching controller code (needed e.g. in log module)
- Compact. You can see at one glance which buttons are used, how the menu is and what requirejs modules are loaded (try that with plain module template api, no matter what additional abstraction is added)
- Flexible. Buttons, Menu, even the complete docheader can be easily different for different views (actions). Without that, controller code would need conditions on actions.
Main module layout view helper needs to be added only once (this is now checked and an exception emitted otherwise) and all other VHs need to be children of that one (which is a strict requirement, which can’t easily be changed).
It is (easily) possible to add HTML outside the main VH (this would result in invalid HTML so the “benefit” in doing so is pretty low).
The view helpers added won’t be view helpers in the sense that they won’t directly render things in the place they are used (which is also true for other core VHs like the VH).
Usage of ModuleTemplate isn’t enforced (which is also a pro, see “Flexible” from above).
- Create ViewHelpers as outlined in this topic
- Leave everything as it is