Hi,
I would like to shift the theme selection process to a Page in the CMS.
I have the following;
class Config extends Page {
static $db = array(
'Theme' => 'Text',
);
function get_current_theme() {
$result = DataObject::get_one('Config');
return $result->Theme;
}
The function returns the value of Theme if I call $get_current_theme from a template but if I call it from mysite/_config.php using
Config::get_current_theme();
I get the following errors, which I assume are because I am ahead of the class construction of SS.
Warning: ClassInfo::dataClassesFor() no parents for Config in sapphire\core\ClassInfo.php on line 49
Warning: Invalid argument supplied for foreach() in sapphire\core\ClassInfo.php on line 50
Fatal error: DataObject::buildSQL: Can't find data classes (classes linked to tables) for Config in sapphire\core\model\DataObject.php on line 1334
Can I achieve the same DB query using the SQLQuery function? If so how, I can't work out the syntax from the doco or api pages.