This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

tetraneon25986
tetraneon25986

Hi everyone,

I can't understand this. In this example trucs is an non empty array. I tried a lot of tips but nothing really correct. When I wrote :

{% for truc in trucs %}

    {{ truc.foo }}

    {% component 'myComponent' truc=truc %}

 {% enfor %}

I can see {{ truc.foo }} but array truc is empty in my component myComponent whereas trucs is available. Could it be linked with the Page execution life cycle handlers ? In that case, when and/or where could I inject truc ?

neilcarpenter
neilcarpenter

It's passed through as a property and you should be able to access it in your components onRender

public function onRender()
{
    $truc = $this->property('truc')
}

Docs explain it here: https://octobercms.com/docs/plugin/components#default-markup

tetraneon25986
tetraneon25986

It works ! Thanks a lot !

And it's better with $this->page['truc'] = $this->property('truc') to reuse with twig !

Last updated

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.