Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming you're using beta5 - you're just configuring your viewhelper wrong. See <a href="https://stackoverflow.com/questions/11392624/how-to-add-custom-view-helpers-to-zend-framework-2-beta5">this post</a> on how to do it correctly.</p> <p>On how to use navigation: I'd create a service in the servicemanager called <code>navigation</code> and put my navigation into a new config-key:</p> <pre><code>return array( 'navigation' =&gt; array( // your navigation config goes here ), 'servicemanager' =&gt; array( 'factories' =&gt; array( 'navigation' =&gt; function($sm) { $config = $sm-&gt;get('Configuration'); $navigation = new \Zend\Navigation\Navigation($config-&gt;get('navigation')); return $navigation; } ), ), 'view_helpers' =&gt; array( 'factories' =&gt; array( 'navigation' =&gt; function($sm) { return new \My\View\Helper\Navigation($sm-&gt;get('navigation')); } ), ), ); </code></pre> <p>(Not sure about the navigation class names. Haven't had a look on them.)</p> <p>This does three things:</p> <ul> <li>Provide a service called <code>navigation</code> pointing to the actual instance if zend's navigation</li> <li>Provide your view helper and hand it a reference to the instance of your navigation</li> <li>Create a new top-level key <code>navigation</code> containing the navigation configuration. Other modules can add custom navigation here without changing anything in your setup.</li> </ul> <p>For example in your controllers you code fetch the navigation instance by calling</p> <pre><code>$this-&gt;getServiceLocator()-&gt;get('navigation'); </code></pre> <p>while in your view helper has access to the navigation by it's constructor:</p> <pre><code>Navigation extends // ... { public function __construct($navigation) { // do anything you want } } </code></pre> <p>Other modules can add entries to your navigation by writing into the same key:</p> <pre><code>return array( 'navigation' =&gt; array( // further navigation entries ), ); </code></pre> <p>Where you put the initial logic (e.g. setting up the services/view helpers) is up to you. I prefer writing a own module for this which can be disabled with a single line of code (resulting in the navigation not being present anymore). But the default module is probably a good place as well. Ultimately you could create your own factory-classes for the navigation and view helper instead of mixing the configuration with your code.</p> <p>Disclaimer: Code's just a draft - not tested.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload