This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Is it possible to access a variable within the YAML section of a page?
For example I have a variable that is set in the backend using the theme form fields, within the HTML portion of the page I can use {{ this.theme.var_name }}
to display it, however I'd also like to display this mid way through the page title, which is defined in the YAML portion of a page template. This doesn't work:-
title: "Some text {{ this.theme.var_name }} some more text"
Ended up working around this using the PHP section of a page:-
<?php
function onEnd() {
$this->page->title = "Title" . $this->theme->var_name. " with variable in";
}
?>
Or the page meta description:-
<?php
function onEnd() {
$this->page->description = "Description " . $this->theme->var_name. " with variable in";
}
?>
stephenkeable said:
Is it possible to access a variable within the YAML section of a page?
For example I have a variable that is set in the backend using the theme form fields, within the HTML portion of the page I can use
{{ this.theme.var_name }}
to display it, however I'd also like to display this mid way through the page title, which is defined in the YAML portion of a page template. This doesn't work:-
title: "Some text {{ this.theme.var_name }} some more text"
did you find a way?
1-3 of 3