To access a specific component, you can use the following methods:
$this->page->components[ 'componentName' ]; // Or just $this->componentName;
It allows you to use method setProperty()
.
In the following example we change the recordsPerPage
property of the collection after the component is initialized:
[collection blogPosts] handle = "Blog\Post" recordsPerPage = 5 == <?php function onStart () { // Overrides posts per page property from 5 to 10. $this->blogPosts->setProperty( 'recordsPerPage', 10 ); } == {% for post in blogPosts %} {{ post.title }} {% endfor %}
If you initialize the component from a partial, you can retrieve the component and change its property this way:
$this->controller->findComponentByName( 'blogPosts' )->setProperty( 'recordsPerPage', 10 );