EdpModuleLayouts icon indicating copy to clipboard operation
EdpModuleLayouts copied to clipboard

Let the users change layouts for modules that have nested names for. ex "Example\MyModule"

Open emcode opened this issue 12 years ago • 3 comments

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.

emcode avatar Apr 06 '13 12:04 emcode

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.

EvanDotPro avatar Aug 20 '13 01:08 EvanDotPro

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.

emcode avatar Oct 23 '13 11:10 emcode

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;
        }

ixtec-zz avatar Dec 18 '13 13:12 ixtec-zz