0

How can we set default layout in zf2 if the layout folder is out side the module directory

enter image description here

1

3 Answers 3

1

You can set the layout anywhere you want it doesn't have to be in the modules directory.

just set it inside your modules config

'view_manager' => array(
    'display_not_found_reason' => true,
    'display_exceptions'       => true,
    'doctype'                  => 'HTML5',
    'not_found_template'       => 'error/404',
    'exception_template'       => 'error/index',
    'template_map' => array(
        'layout/layout'           => '/anypath/you/want/view/layout/layout.phtml',
    ),
    'template_path_stack' => array(
       '/anypath/you/want/view',
    ),
),
Sign up to request clarification or add additional context in comments.

1 Comment

just starting with zf2, i have two module album and user which module.config.php(in album or user) should i choose to set the default one? i can see this code as 'template_map' => array( 'layout/layout' => DIR . '/../view/layout/layout.phtml',
0

As per the question posted the answer by @Andrew is correct .

When i notice the working of layout in zf2 i came to certain conclusion

  1. Able to set the layout folder anyway in application environment
  2. Only one layout is taken for all the modules , the layout taken is from the last module mentioned in application.config.php

For example

  'modules' => array(
        'Album',              
        'Testlist',
        'Customer',
        'Application',
        'User',

    ),

Then the user layout will be taken .

if we have only one layout in the application this will be fine

To switching between layouts in the module came across http://www.webtrafficexchange.com/zf2-configure-layout-each-module-edpmodulelayouts which seems to be useful

Comments

0

The default layout is layout/layout configured in the view manager.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.