Reputation: 14862
I am writing a zend application and trying to keep the functionality as modular as possible. Basically I want to drop the folder into the application and have instant functionality.
Anywho; I'm trying to create sidebar links from each module. The method I'm using is to use the bootstrap:
Here is the function in my bootstrap file. I've set the routes in another function.
public function _initNavigation()
{
$navigation = new Zend_Navigation();
$navigation->addPages(
array(
array(
'label' => 'Link Name',
'route' => 'routeA',
'class' => 'heading'
),
array(
'label' => 'Link Name',
'route' => 'routeA',
'params'=>array('param' => 'value'),
),
array(
'label' => 'Link Name',
'params'=>array('param' => 'value'),
'route' => 'routeA'
)
)
);
$this->bootstrap('layout'); //this line giving error :(
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->navigation($navigation);
The error I was getting was:
Resource matching "layout" not found
After some head banging I found that I had to put the module name in front of the resourse in the config/application.ini file, eg:
moduleA.resources.layout.layoutPath = APPLICATION_PATH "/modules/moduleA/views/scripts"
Now here's the question: how do I get the layout resource using a single resource? i.e. without specifying the module name for each new module I use?
Upvotes: 0
Views: 3093
Reputation: 14862
Made answer new post
After a LOT of googling (when did THAT become a replacement for 'searching'?) I came across Leonard Dronkers' "Zend Framework Module Config The Easy Way".
Basically, add this to your module's bootstrap file
/**
* Load config.ini file for this module.
*/
protected function _initModuleConfig()
{
// load ini file
$iniOptions = new Zend_Config_Ini(dirname(__FILE__) . '/configs/config.ini');
// Set this bootstrap options
$this->setOptions($iniOptions->toArray());
}
And place a config.ini file in a config folder in your module (eg /modules/news/config/config.ini) and place your module specific settings there.
That's it. Fantastic!
Upvotes: 2