How to not "share" properties between components of the same name


I have a component called several times in my page, with some parameters :

{% component 'mycomponent' param = "test" %}

{% component 'mycomponent' %}

The issue here is that if I don’t redefine the “param” parameter in my second component, the value is still “test”, the only solution is to redefine it as empty like that :

{% component 'mycomponent' param="" %}

It can do the job, but my component have many many params :

{% component 'mycomponent' param1 = "test" param2 = "test" param3 = "test" param4="test" etc... %}

I’m looking for a way (if possible) to reset parameters values between my components call. I know that I could have several times the same component with different name, but we are talking about a component I use maybe 10 or 20 times in a page and it’s really not a solution to me to add a new component each time I need to call it.

Thank you for your tips


You can add this to your component

public function onRender () {
{% component 'mycomponent' param="test" %}  this will output test
{% component 'mycomponent' param="test2" %}  this will output test2

Thank you for your answer, this is not exactly what I’m looking for. I’m already retrieving my component properties with $this->property(‘param’). What I want is the followig :

{% component 'mycomponent' param="test" %}  this output test
{% component 'mycomponent' %}  I want this to output nothing, actually it output "test"

Notice that I can’t have 2 different components.

Is there a solution to this ?

Thank you

this is the only way

{% component 'mycomponent' param="test" %} output test
{% component 'mycomponent' param="" %}  output nothing

Shame, this make my whole plugin idea useless :confused: . If somebody have a method, even a hacky one to “reset” parameters values between different call of the same component, I’m really interested.

Best regards,

Now i understand what you want, you can set property to null after use.

public function onRender()
    // some logic code

or set property to null in component template

{% do __SELF__.setProperty('param',null) %}

Hope this help!


Hum, that’s an interesting idea, I will test that tomorroy and let you informer. Thank you very much !

Your solution worked like a charm. Thank you very much !