EdpModuleLayouts
EdpModuleLayouts copied to clipboard
Let the users change layouts for modules that have nested names for. ex "Example\MyModule"
Sometimes it is useful to have few modules for some project grouped under one namespace:
MyProject\System MyProject\Page MyProject\User
Currently EdpModuleLayouts does not work for such module names:
array( 'module_layouts' => array( 'MyProject\System' => 'layout/system-layout', // <--- this won't work 'MyProject\Page' => 'layout/page-layout', // <--- this won't work either ), );
I've fixed that.
This assumes they will always have a Controller sub-namespace... While it might be true in most cases, I'm not sure we should hard-code such an assumption. I think there is a cleaner way this could be implemented. Basically count the number of namespace identifiers in the module specified in the config, and set a substring offset based on that.
Hey, can you look at this last commit? I think i solved this, but maybe you have some better idea, any comments or suggestions appreciated.
This here is quicker and simpler, use the classname as key, and first check if there is a match for it, before testing for the namespace as key, just insert these few lines:
if (isset($config['module_layouts'][$controllerClass])) {
$controller->layout($config['module_layouts'][$controllerClass]);
return;
}