Global component in Symfony
I am currently implementing the navigation of the website (multilevel menu, having current page highlighted). As nav开发者_运维知识库igation part will be included for virtually all modules, I first made it a global partial. But logic for selection of "current page" is quite complicated in some situations, I am thinking of using a component for the navigation.
The problem is that symfony allows to have global partials, but not global components. So is there a "nice symfony way" to do this?
There isn't a mechanism for this as such. I usually end up creating an empty module called default and putting stuff like that in there.
What's wrong with:
<?php include_component('someModule', 'navigationComponent') ?>
... where you store it in some general module (e.g. "general") and call it wherever you want, including your layouts. Isn't that global enough?
This is your solution:
Create the yourproject/yourapp/templates/_globalpartial.php with this content:
<?php include_component('yourmodule', 'yourcomponent'); ?>
And use this globalpartial.php in yourproject/yourapp/templates/layout.php
精彩评论