Set page property in controller


#1

Is it possible to set/override a property in a controller?


#2

yes, you can retrieve properties and also set new values:

$this->document->setProperty('propertyName', 'text', 'new value')->save();

#3

OK - that works.

When calling an action by a static route, how to set properties in this case? If I set them like shown the way above, the properties are set in the root document (1). That’s not what I want to do. I want to set the properties “temporary” for an action call by static route.

THX


#4

You can load any document by

\Pimcore\Model\Document::getById();
\Pimcore\Model\Document::getByPath();

#5

So I have to create a kind of “dummy” document to use with the controller action?


#6

You are approaching the wrong use-case for properties hear. If you wanna pass options to a sub-action you can do so by using symfony sub-requests.