New answers tagged

3

Just to provide a slight improvement to @Matanya's solution: Instead of filtering the array of Neo blocks, you can limit your query to the blocks you actually want. This way, you're not loading blocks you don't actually need. For example, to only get level one blocks: {% for module in entry.pageBuilder.level(1).all() %} See the Templating docs for Neo for ...


2

This is a Twig exception. When you are using an if condition on the for loop itself Twig has no way of knowing how many elements will be iterated over, or whether it is the first or last element. See: https://github.com/twigphp/Twig/issues/687 I see that support for using if on for loops was removed altogether on v3: https://github.com/twigphp/Twig/commit/...


Top 50 recent answers are included