1
1
1alexandr2015-01-14 16:30:04
symfony
1alexandr, 2015-01-14 16:30:04

symfony2. How to make a list of something from the database displayed on all pages?

Hello dear experts!
Please help me solve the problem, I need to display the category block on all pages. There are 18 pages in total, and 18 routes for them. How to do this without passing a selection with categories in each controller and action?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Z
zugo, 2015-01-14
@1alexandr

The most obvious is to call the controller that displays the category block in the base layout, from which all other views are inherited.

{% block categories %}
  <h2>Категории</h2>
  {{ render(controller('YourBundle:YourCategoryController:index')) }}
{% endblock %}

A
Alexander Evgenievich, 2015-01-14
@banderos120

You can look towards services, or TwigExtension

A
Alexey Dubinin, 2015-01-15
@tier2003

What about the onKernelRequest event?

R
romashka_sky, 2015-01-16
@romashka_sky

You can use the block from sonata-project.org/bundles/block/master/doc/refere...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question