0
Welcome Guest! Login
0 items Join Now

Trying to understand menu particle twig file

    • shenk's Avatar
    • shenk
    • Hero Rocketeer
    • Posts: 424
    • Thanks: 11

    Trying to understand menu particle twig file

    Posted 8 years 7 months ago
    • I think particle is the core feature of gantry 5, if one doesn't understand and master particles, then he is not reallying taking full advantage of gantry 5. Although the twig/yaml thing seem quite intimidating to non-developers, but I think particle systme does offer an much easier alternative for users who want to have their own module but lack the skill to make one. So I'm determined to put some efforts on learning how to customize particles.

      I have successfully created my own particles and overrided some existing ones, now I set out to customize menu particle. This one looks a lot different from others, so I have lots of questions, here are the most essencial ones which I don't think is easy to get answer from googling:

      1. In documentation it says
      {% extends '@nucleus/partials/particle.html.twig' %}

      "is a must-have element for all Particle Twig Files.", but I couldn't find it in menu.html.twig, insteadly, I find this line

      {% set menu = gantry.menu.instance(particle) %}

      Is it equivalent to the former?

      2. Another part the documentation deems 'required' is "{% block particle %} and {% endblock %} ", but they are also nowhere to be found in menu.html.twig, why?

      3.In line 116, there is

      {% if menu.root.count() %}

      Where can I find the definition of this 'menu.root.count()'?
    • Last Edit: 8 years 7 months ago by shenk.
    • Matias Griese's Avatar
    • Matias Griese
    • Sr. Rocketeer
    • Posts: 249
    • Thanks: 104
    • Lead Developer

    Re: Trying to understand menu particle twig file

    Posted 8 years 7 months ago
    • 1.

      You do not need to really extend the base particle; you can also choose not to extend it or to extend another existing particle. The reason why we say it should be there is that the documentation is relaying the fact that it is extending that file. :)

      Basically if you take a look into media/gantry5/engines/nucleus/templates/particle.html.twig , you will see that it gives you possibility to add css or js for your particle.

      2.

      Above file will also define block named particle and is as such needed if you follow the instructions.

      3.

      efinition for menu is in line 1 of the same file. It basically makes a call to Gantry to fetch menu instance by using parameters given in admin.
    • Gantry 5, enjoy!

Time to create page: 0.050 seconds