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

kh_october13612
kh_october13612

I need to have a variable global to a CMS page. Seems like viewBag can do the trick.


title = "test"
url = "/test"
layout = "default"
is_hidden = 0

[viewBag]

I also need to change this global variable at the component level. I am doing it this way.


{% if viewBag.property("counter") %}
{% do viewBag.setProperty("counter",1 +  viewBag.counter ) %}
{% else %}
{% do viewBag.setProperty("counter",100) %}
{% endif %}

{{ viewBag.counter }}

It seems to work. The problem is I cannot find documentation for setProperty(). Is this the correct way of doing it ? Or there is other proper way of doing this ?

1-1 of 1

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