Ad

Custom Page Variable In OctoberCMS

- 1 answer

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.

Ad

Answer

It seems this was the old way of defining all stuff in single view (visual representation)

now its divided in 3 portion

1stname and url(slug) then 2ndmarkup(html) section

enter image description here

3rdcode section

enter image description here

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.

Ad
source: stackoverflow.com
Ad