このパターンはうまくいくと思います...
テーマフォルダの構造
/path/to/themes
/path/to/themes/some_theme
/path/to/themes/some_theme/layout.phtml
/path/to/themes/another_theme
/path/to/themes/another_theme/layout.phtml
config / module.config.php
return array(
'view_manager' => array(
'template_path_stack' => array(
'/path/to/themes',
),
),
);
Module.php
namespace Something;
class Module
{
public function onBootstrap(\Zend\EventManager\EventInterface $e)
{
$application = $e->getApplication();
$em = $application->getEventManager();
$em->attach('route', function($e) {
// decide which theme to use by get parameter
// $layout = 'some_theme/layout';
// $layout = 'another_theme/layout';
$e->getViewModel()->setTemplate($layout);
});
}
}
//編集:controllerLoaderの代わりにrouteイベントを使用するように変更