Skip to content
Advertisement

Twig only showing first array level

My firstime ever asking a question in a forum. I normally use blade for templating but the standalone Twig is simpler to install. So I have this issue here i hope you can help me.

JavaScript

I’am traying to achieve something like this, but the code prints nothing. In the other hand if a do this:

JavaScript

works fine, but not what I’am trying to do. Thanks

Advertisement

Answer

I suggest you change your $breadcrumbs to

JavaScript

This makes your array more readable, you can easily see the title and its related link (instead of having two “unrelated” arrays).

In your twig template you can then use:

JavaScript

Solution for more attributes:

If you want to add more attributes to your breadcrumbs you can use something like:

JavaScript

In your twig file you then use:

JavaScript

Will output:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement