PHP code example of xruff / navigation

1. Go to this page and download the library: Download xruff/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/ */

    

xruff / navigation example snippets


use Nette;
use XRuff\Components\Navigation\Navigation;

abstract class BasePresenter extends Nette\Application\UI\Presenter
{
	/** @var Navigation @inject */
	public $navigationFactory;

	protected function createComponentNavigation($name) {
		$nav = $this->navigationFactory->create($this);
		$nav->setupHomepage('Homepage', $this->link('Homepage:'));
		return $nav;
	}
}

use XRuff\Components\Navigation\Navigation;

class SomePresenter extends BasePresenter
{
	/** @var XRuff\Components\Navigation\Navigation $nav */
	private $nav;

	protected function startup()
	{
		parent::startup();
		$this->nav = $this['navigation']->add('Company name', $this->link('Company:'));
	}

	public function renderDefault()
	{
		$this->nav = $this->nav->add('Overview', false);
		$this->nav->setCurrent(true);
	}

	public function renderDepartment()
	{
		$this->nav = $this->nav->add('Department name', false);
		$this->nav->setCurrent(true);
	}

	public function renderOther()
	{

		$sec = $this->nav->add('Section', $this->link('Category:', ['id' => 1]));
		$article = $sec->add('Article', $this->link('Article:', ['id' => 1]));
		$this->nav->setCurrentNode($article);
		// or $article->setCurrent(TRUE);
	}
}