Skip to content

Instantly share code, notes, and snippets.

@bugzbrown
Last active July 7, 2021 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bugzbrown/118a79322c00862a07f52e75705e23b7 to your computer and use it in GitHub Desktop.
Save bugzbrown/118a79322c00862a07f52e75705e23b7 to your computer and use it in GitHub Desktop.
Get Plugin System Settings from your templates with a twig extension in OctoberCMS
/*
* In your plugin.php file add the following function
*/
<?php
//...
public function registerMarkupTags()
{
return [
'functions' => [
'getSettings' => function($setting, $default)
{
return Settings::get($setting, $default);
}
]
];
}
//...
/********
** IN YOUR TEMPLATES AND PARTIALS, YOU CAN NOW ACCESS THE SETTINGS USING THE FUNCTION getSettings
*********/
{{ getSettings('mySetting', 'default value if not set') }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment