Q
Q
Qixing2015-03-23 05:50:01
PHP
Qixing, 2015-03-23 05:50:01

How to properly template a dropdown menu in twig?

I display the menu not everywhere, but on some pages.
Menu generation
:base.html.twig

{% block leftCol %}
                    {% render( controller("MyBundle:Category:list")) %}
{% endblock %}

Sample Template
<li  class="expanded">
          <a href="">itemN</a>
          <a href="">itemN</a>
          <a href="">itemN</a>
  </li>

  <li  >
          <a href="">itemN</a>
          <a href="">itemN</a>
          <a href="">itemN</a>
  </li>

In general, the menu is collapsed, without class="expanded"
But when, for example, the user is in a product category, then you need to expand it, add class="expanded", based on the categoryId .
How can I pass this parameter correctly?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question