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

stephenkeable
stephenkeable

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"

stephenkeable
stephenkeable

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";
}
?>
fangli.alexandru64736
fangli.alexandru64736

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

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