Advertisement
Guest User

Untitled

a guest
Sep 13th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. Module.php
  2.  
  3. public function getServiceConfig()
  4. {
  5. return array(
  6. 'factories' => array(
  7. 'navigation' => 'ModuleNamespace\Navigation\Service\NavigationFactory',
  8. )
  9. );
  10. }
  11.  
  12. ModuleNamespace\Navigation\Service\NavigationFactory
  13.  
  14. <?php
  15.  
  16. namespace ModuleNamespace\Navigation\Service;
  17.  
  18. use Zend\ServiceManager\ServiceLocatorInterface;
  19.  
  20. class NavigationFactory extends \Zend\Navigation\Service\DefaultNavigationFactory
  21. {
  22. public function createService(ServiceLocatorInterface $serviceLocator)
  23. {
  24. return new \ModuleNamespace\Model\Navigation();
  25. }
  26. }
  27.  
  28. ModuleNamespace\Model;
  29.  
  30. class Navigation extends \Zend\Navigation\Navigation
  31. {
  32. public function __construct()
  33. {
  34. $home = new \Zend\Navigation\Page\Mvc();
  35.  
  36. $home->setLabel('Home')
  37. ->setController('index')
  38. ->setAction('index');
  39.  
  40. $this->addPage($home);
  41.  
  42.  
  43. $contact = new \Zend\Navigation\Page\Mvc();
  44.  
  45. $contact->setLabel('Contact')
  46. ->setController('contact')
  47. ->setAction('index');
  48.  
  49. $this->addPage($contact);
  50. }
  51. }
  52.  
  53. layout.phtml
  54.  
  55. <?php echo $this->navigation('navigation')
  56. ->menu()
  57. ->setMaxDepth(0)
  58. ->setRenderInvisible(false) ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement