How to Access Application Config from View in Zend Framework 2 (zf2)? -


i wanted access application config view. how can achieve in zf 2?

actually shouldn't need access application config inside view. in mvc, views responsible displaying/rendering data (output) , shouldn't contain business or application logic.

if want can pass view in controller this:

<?php namespace yourmodule\controller;  use zend\view\model\viewmodel;  // ...  public function anyaction() {     $config = $this->getservicelocator()->get('config');     $viewmodel = new viewmodel();     $viewmodel->setvariables(array('config' => $config ));     return $viewmodel; }  // ... ?> 

so in view.phtml file;

<div class="foo">  ...  <?php echo $this->config; ?>  ... </div> 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -