I am new to ZF and I have problem with even simple tasks.
I would like to have dynamically generated menu on every page. To do that I should fill $this->view
with data. OK, but to do that, I would have to fill view separately in every controller I made. This would lead to code duplication.
The most natural solution, that I see, is to create base controller class for all my controllers, but I read, that this is not a good practice in ZF. So how should I do that? Even if it is only one line of duplicated code (eg. $this->view->menu = $reusableObject->generateMenuData()
), I don't like it.
What is the best practice for such a solution? How could you solve this problem?
I am using ZF 1.11.
EDIT: I would like to mention, that I would be happy to know how to do that using some kind of phtml file rather than concatinating html tags.
EDIT2: The point is, I am not really interested in only navigation links. Instead of menu with links that could be eg. list of latest post, but on every page, so in every controller. I am particularly interested in "how to this kind of stuff in ZF".