Skip to content

Instantly share code, notes, and snippets.

@akroii
Created March 8, 2021 07:09
Show Gist options
  • Save akroii/b56e286db3cbc5f27f9038d4df665315 to your computer and use it in GitHub Desktop.
Save akroii/b56e286db3cbc5f27f9038d4df665315 to your computer and use it in GitHub Desktop.
Establishing an database connection
/** @var PageModel $objPage */
global $objPage;
$this->import('Database');
$vars = array();
// Get the global theme variables
$objTheme = $this->Database->prepare("SELECT tl_theme.vars FROM tl_theme, tl_layout WHERE tl_theme.id=tl_layout.pid AND tl_layout.id=?")
->limit(1)
->execute($objPage->layoutId);
if ($objTheme->vars != '' && \is_array(($tmp = StringUtil::deserialize($objTheme->vars))))
{
foreach ($tmp as $v)
{
// remove $ for backwards compatability with existing entries on the key
$vars[str_replace('$', '', $v['key'])] = $v['value'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment