In symfony cmf I like to create the following:
- create a menu item called inside
- create a container block called insideBlock
- create multiple static contents, they should have as parent the container block
if a user clicks the menu inside, all items from static content should be displayed, which have as parent the insideBlock
I did not figure out how to do this. Of course I don't like to programs a function just for inside, since I would like other menus behaving the same way.
I am able to link a menu item to a static content and display this single content, but as soon as I select the container block, the menu item disappears...
EDIT
I have done this:
in my controller add a function like this:
/** * @Route("/{_locale}/empfang", name="empfang_display_all") */ public function empfangAction(Request $request) { $documentManager = $this->get('doctrine_phpcr')->getManager(); $content = $documentManager->find(null, '/cms/content/empfangsgebiet'); return $this->render('empfang/empfang.html.twig', [ 'contents' => $content ]); }
- added as route to the menu item empfang_display_all
- static content set parent to the container
- in the view
``{ % set index = 0 %}
{% for child in children %}
{% if (child.name != "banner") and (isInstanceof(child, 'ContainerBlock') == false) %}
<div class="{{ cycle(section1, index) }}">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="top-title">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
{% if isInstanceof(child, 'DemoSeoContent') %}
{{ child.body|raw }}
{% else %}
{{ sonata_block_render({ 'name': child.id }) }}
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% set index = index + 1 %}
{% endif %}
{% endfor%}
I would now like to have the following line more dynamic
$content = $documentManager->find(null, '/cms/content/empfangsgebiet');
Preferable I would like to have it like this:
/**
* @Route("/{_locale}/empfang/{path}", name="empfang_display_all")
*/
public function empfangAction(Request $request, $path)
{
$content = $documentManager->find(null, $path);
}