Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

emcode
Copy link

@emcode emcode commented Apr 6, 2013

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.

@EvanDotPro
Copy link
Owner

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.

- we do not rely on \\Controller subnamespace anymore
- we have more freedom when specyfying module => layout mapping
  as only beginning of namespace have to match
- remember to set most specific aliases as first, under
  module_layouts config key
@emcode
Copy link
Author

emcode commented Oct 23, 2013

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.

@ixtec-zz
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants