Question

I tried dump variables in block template (block_core_children_pages.html.twig) by {{ dump() }} but it turn into blank page. Anybody have same problem? and I have some questions also:

  1. How to pass a variable from function: {{ sonata_page_render_container('footer', 'global' ) }} to template ?
  2. What are variables is passed by default to block template?

Thanksss alot.

Était-ce utile?

La solution

The sonata_page_render_container function takes the following arguments:

public function renderContainer($name, $page = null, array $options = array())

So you have the third argument to specify some options/settings to add to your block, like this:

{{ sonata_page_render_container('footer', 'global', {mysetting: myvalue}) }}

After that, you can modify your execute() BlockService's method to use the settings you passed.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top