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

cmdillon
cmdillon

hi! i made a plugin and i would like to retrieve a property from it via twig. i have placed "{{ SELF.prop }}" in my partial which is in the component partials directory, but the property does not show when i access the page. i know that the property has a value, because i set a default value.

Algad
Algad

You can write the code below in "YourCustomComponent.php"

public function getProperty($propertyName) { return $this->property($propertyName); }

then in your view you can do

{% set title = __SELF__.getProperty('title') %}

{% set description = __SELF__.getProperty('description') %}

Regards

Last updated

cmdillon
cmdillon

@algad: thanx! i tried that but it doesn't work. still no output of the property.

cmdillon
cmdillon

ok, got it to work changed to: public function getProperty() { return $this->property('propertyName'); }

thanx for pointing me in the right direction.

Last updated

contact29602
contact29602

Thanks for the insight in this thread -- the post, the suggested solution, and the caveat (still seems to need the workaround)

1-5 of 5

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