Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MichaelHabib/be0948e61c424be5ab6019a31093f005 to your computer and use it in GitHub Desktop.
Save MichaelHabib/be0948e61c424be5ab6019a31093f005 to your computer and use it in GitHub Desktop.
October CMS : How to parse twig & bracket variables stored in a string or a field ?
// parsing twig
$theme = Cms\Classes\Theme::getActiveTheme();
if(($stringContainingTwig = $this['page']['meta_title']) !== null ){
$page_meta_title = Twig::parse($stringContainingTwig, [
'varName' => "variable value!",
'separator' => $theme->title_separator ?: ' _ ' ,
'title' => $this['page']['title'],
'business_name' => $theme->business_name,
]);
}else{
$page_meta_title = $this['page']['title'].' - '.$theme->business_name;
}
$this['page_meta_title'] = $page_meta_title;
// parsing bracket
// ToDo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment