R Down
R Down

Reputation: 2289

Zend Framework 2 and AngularJS

Trying to implement a ZF2 app using AngularJS for all my frontend. I've got the ZF app setup and going, but I'm not sure how to go about making only 1 layout.html for the entire app with will contain the <div data-ng-view></div>?

I guess this really boils down to: How do I implement 1 global layout.html file in ZF2 where I have multiple modules?

Upvotes: 0

Views: 4500

Answers (1)

Asgrim
Asgrim

Reputation: 88

If you don't know already, ZF2 module configuration is all smashed together into one big configuration. The order that the modules are listed in your config/application.config.php depicts the order in which modules are loaded.

Once you realise this, you can use this to your advantage - in the last module that loads (for example your Application module, make sure you configure the layout there. An example layout configuration might look like this:

return array(
    'view_manager' => array(
        'template_map' => array(
            'layout/layout' => __DIR__ . '/../view/layout/layout.phtml'
        ),
    ),
);

This can be seen in the ZF2 skeleton application.

In most instances (not all), I'd recommend that your Application module is the last module loaded.

Upvotes: 1

Related Questions