Override a component property from the php code section
2
You can access all components on the current page via
$this->page->components;
this allows you to use the setProperty
method on the component class to override specific properties dynamically from a page's or layout's code section.
[products]
perPage = 9
==
function onStart()
{
// Override the previous setting of 9 products per page.
$this->page->components['products']->setProperty('perPage', 3);
}
==
{% component 'products' %}
Can the component property be set from the partial?
For example partial with code:
function onStart() { $this->controller->addComponent('\OFFLINE\Mall\Components\Products', 'products', ['sort' => 'latest', 'perPage' => 2]);
}