Answer the question
In order to leave comments, you need to log in
Sub request or service?
the layout consists of 4 parts: header, content, sidebar, footer
data for the middle (content, sidebar) I plan to return the controller
public function indexAction()
{
...
return $this->render($tpl, [
"content" => $this->get('service')->getDataForCurrentPage(),
"sidebarContent" => $this->get('service')->getSidebar3()
])
}
<div class="wrapper">
{% for item in getDataForHeader() %}
<div class=" .. ." >
{{ item.render() }}
</div>
{% endfor %}
</div>
{% set layoutData = getLayoutData() %}
.....
{% for item in layoutData.header %}
...
{% endfor %}
.......
.....
{% for item in layoutData.footer %}
some rendering
{% endfor %}
{ endfor %}
Answer the question
In order to leave comments, you need to log in
The first option is quite normal.
The second one is pretty pointless. Fence an extension for something it's not needed for.
The third one is not very good, because in this case, the far-left controllers will have to know something about the header, although they are doing something completely different.
The fourth one is also not the best idea.
Fifth - perhaps, too.
I would choose the first option, when a separate action is responsible for displaying data for the header or sidebar.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question