Closed PaulMorel closed 5 years ago
Hey PaulMorel,
I tested this and found out that it works when saving page.children to a variable in a controller and passing it to the template. Also placing your code in an if block something like this helps:
{% if(page.hasChildren) %}
{% endif %}
Sry for the inconvenience. It has definitely something to do with twig. I will dig deeper to find the reason for this.
I hope you can work with it in the meantime with these tips.
I found the reason for this:
Twig calls to specific methods, like for instance page.children
sometimes return NULL
. This can occur, if there is also a public variable which is only initialized after calling the corresponding method.
{{ page.children }}
returns NULL
, because the public variable is returned. Please call the method instead like this: {{ page.children() }}
.
Started a new project and wanted to use Twig. I have a dead simple template and
page.children
returnsNULL
.Using Kirby 3.1.4.
{{ dump( page.children ) }}
returnsNULL
and nothing inside thefor
block is rendered.Everything works fine in an equivalent PHP template:
This template successfully outputs all of the page's children's titles.
dump()
outputs aPages
object.Any ideas what might be happening?