Common presenter in modules
- pistols
- Member | 26
Hello There, I have these modules in my app
admin, dealer
No there is an customer functionality a did for dealer. it has its presenter
dealerModule/presenters/CustomerPresenter.php
and his templates
dealerModule/templates/Customer/default.latte
dealerModule/templates/Customer/detail.latte
So far so good.
Now this CustomerPresenter functionality must be implemented into the admin module as well.
What is the best practice for this? I dont want to just copy the presenter and its templates.
Second thing I tried to move the presenter to a BasePresenters folder and just inherit its code to the presenter in the dealerModule. That worked partialy. It failed on the missing templates.
Thanks you for your suggestions
- dkorpar
- Member | 135
You need to set templates directory as well in BasePresenter…
you can override formatTemplateFiles function which returns array of possible
location…
so something like:
public function formatTemplateFiles()
{
$locations = parent::formatTemplateFiles();
$locations[] = __DIR__ . "/templates/$this->view.latte";
return $locations;
}
ps I wrote code here, did not test it, but you get the point :)