I'm extending LeftAndMain to create a custom CMS area. This is loosely based on the Settings area of the CMS.
After looking into how the Settings area is put together in code, I noticed this function that sets the theme to display tabs correctly:
public function getResponseNegotiator() {
$neg = parent::getResponseNegotiator();
$controller = $this;
$neg->setCallback('CurrentForm', function() use(&$controller) {
return $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
});
return $neg;
}
This gets a template located in /cms/templates/Includes/CMSSettingsController_Content.ss
So I duplicated this in my custom LeftAndMain child and created a duplicate template. This is not a module as it is very specific to the application and we want to keep code/templates in one area of the file system.
When I do the same as above, getTemplatesWithSuffix only returns LeftAndMain.ss.
I have stepped through the code and found that even though my custom template is found, it is ignored because $theme is null in this subsequent function:
SSViewer.php
public static function hasTemplate($templates) {
$manifest = SS_TemplateLoader::instance()->getManifest();
if(Config::inst()->get('SSViewer', 'theme_enabled')) {
$theme = Config::inst()->get('SSViewer', 'theme');
} else {
$theme = null;
}
foreach ((array) $templates as $template) {
if ($manifest->getCandidateTemplate($template, $theme)) return true;
}
return false;
}
So how do I make the CMS aware of the theme? Or is a way of doing this?