Reputation: 93
Is it possible to use custom page variable in Configuration section in OctoberCMS? When I do this:
url = "/blog"
layout = "default"
custom_var = "value"
==
{{ custom_var }}
my custom_var is deleting when edit page from admin panel.
Upvotes: 1
Views: 1449
Reputation: 109
Yes, its possible to set custom variable into page. you can try the following code into the php section
function onEnd() {
$this->page->custom_var = 'some data';
}
And then you can use this custom_var into your layout file like
{{ this.page.custom_var }}
Upvotes: 2
Reputation: 399
If you want to define new variables inside markup you can use following syntax:
{% set custom_var = 'some data' %}
Upvotes: 0
Reputation: 9693
It seems this was the old
way of defining all stuff in single view (visual representation)
now its divided in 3 portion
1st name and url(slug)
then 2nd markup(html) section
3rd code section
so you can follow new way
of declaring
things and it should work
use code section
add this
public function onStart() {
$this['custom_var'] = 'some value';
}
use markup
section and add this
<h1>{{ custom_var }}</h1>
it will work, still any issue please comment.
Upvotes: 2