Zf2 Naviagation Custom Active Page Call in layout/view $nav = $this->navigation('Navigation'); $pages = $nav->getContainer()->getPages(); foreach ($pages as $page) { if ($page->getId() == 'admin') { $page->setActive(true); } }
In this article I will show a simple way to log every change to doctrine 2 entity. This one will not be copy / paste. Just check out the code and help yourself. 1. Create event service /** * @developer Ivan Gospodinow */ namespace Application\Service; use Application\Entity\DbLogEntity; use Application\Entity\AbstractEntity; use Doctrine\Common\Persistence\Event\LifecycleEventArgs; use \DateTime; class DoctrineLogChangesService […]
How to change layout for ajax requests in Zend Framework 2 1. Module.php public function onBootstrap(MvcEvent $e) { $e->getApplication() ->getEventManager() ->getSharedManager() ->attach( 'Zend\Mvc\Controller\AbstractController', 'dispatch', function ($e) { $controller = $e->getTarget(); if ($controller->getRequest() instanceof HttpRequest) { if ($controller->getRequest()->isXmlHttpRequest()) { $controller->layout('layout/ajax'); } } }, 100 ); } 2. module.config.php Add the layout path 'view_manager' => array( 'template_map' […]
This post is a follow up from : zend framework 2 acl in 5 minutes Step 1 Code in config/autoload/global.php 'navigation' => array( 'default'=> array( array( 'label' => 'Home', 'route' => 'home', 'resource'=> 'home', ), array( 'label' => 'Login', 'route' => 'login', 'resource'=> 'login', ), array( 'label' => 'Register', 'route' => 'register', 'resource'=> 'register', ), […]
There is a easy way to get zend framework 2 base path with domain name in layout. 1. In layout.phtml $homeUrl = $this->url('home',array(),array('force_canonical' => true)); 2.Adding home route in module.config.php 'home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'Application\Controller\Index', 'action' => 'index', ), ), ), Simple […]