PHP code example of holabs / navigation

1. Go to this page and download the library: Download holabs/navigation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

holabs / navigation example snippets


 

namespace App\Presenters;

use Holabs\Navigation\Manager;
use Nette\Application\UI\Presenter;

/**
 * @author       Tomáš Holan <[email protected]>
 * @copyright    Copyright © 2017, Tomáš Holan [www.tomasholan.cz]
 */
abstract class BasePresenter extends Presenter {

	/** @var Manager @inject */
	public $navigation;


	public function startup() {
		parent::startup();
		
		$section = $this->navigation->getSection('main');
		$section->createItem('dashboard', 'Main dashboard')
			->setLink('Dashboard:default')
			->setIcon('dashboard')
			->setLabel('new', 'red')
			->addActiveCondition(function() { // Set active callback
				return $this->isLinkCurrent('Dashboard:*');
			})
			->addRenderCondition(function () { // Set render callback
				return $this->getUser()->isAllowed('Dashboard', 'default');
			});
	
		$section = $this->navigation->getSection('settings');
		$section->createItem('users', 'Users settings')
			->setLink('Users:default')
			->setIcon('group', 'green')
			->addActiveCondition(function() {
				return $this->isLinkCurrent('Users:*');
			})
			->addRenderCondition(function () {
				return $this->getUser()->isAllowed('Users', 'default');
			});
	}
	
	public function beforeRender() {
		parent::beforeRender();
		$this->template->sections = $this->navigation->getSections();
	}
}