PHPackages                             pavelkucera/navigation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pavelkucera/navigation

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pavelkucera/navigation
======================

v1.0.0(13y ago)629BSD-3-ClausePHPPHP &gt;=5.3.0

Since Jan 9Pushed 13y ago2 watchersCompare

[ Source](https://github.com/pavelkucera/navigation)[ Packagist](https://packagist.org/packages/pavelkucera/navigation)[ RSS](/packages/pavelkucera-navigation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Navigation
==========

[](#navigation)

A simple tool helping you to create a structured navigation really fast.

License
-------

[](#license)

BSD 3-Clause

Dependencies
------------

[](#dependencies)

- [the Nette Framework](http://nette.org) any version
- php &gt;= 5.3.0

Installation
------------

[](#installation)

Through composer:

```
$ composer install pavelkucera/navigation

```

Usage
-----

[](#usage)

### I wanna a navigation now!

[](#i-wanna-a-navigation-now)

It is a way too easy to create a structured navigation.

```
use PK\Navigation\Node;

$navigation = new Node();
$navigation->addChild(new Node('Homepage', 'Homepage:'));
$navigation->addChild(new Node('Blog:', 'Blog:'));
$portfolio = $navigation->addChild(new Node('Portfolio'));
	$portfolio->addChild(new Node('Nette', 'Portfolio:nette'));
	$portfolio->addChild(new Node('JavaScript', 'Portfolio:javascript'));
	$portfolio->addChild(new Node('Android', 'Portfolio:android'));
```

There is no limitation to the number of children.

### I need to render it

[](#i-need-to-render-it)

Since every site has its own way of rendering its navigation, this tool **does not** come with any “official” `Nette\Application\UI\Control` implementation. Nevertheless you can find an example in the examples directory.

The tool provides a view object you can easily read.

```
use PK\Navigation\Node;
use PK\Navigation\NodeView;

$navigation = new Node('navigation');
$navigation->addChild(new Node('Homepage', 'Homepage:'));
$navigation->addChild(new Node('Blog:', 'Blog:'));

$view = $navigation->render(new NodeView());
$view->label; // 'navigation'
$view->link; // NULL
$view->active; // FALSE
$view->children; // array(2)
```

### I need to set the order

[](#i-need-to-set-the-order)

Pass the child priority as the second parameter (higher is better). In case of the same priority, time is critical (sooner is better).

```
use PK\Navigation\Node;

$navigation = new Node();
$navigation->addChild(new Node('Homepage', 'Homepage:'), 1);
$navigation->addChild(new Node('Blog:', 'Blog:'), 5);
```

### I need to mark active node(s)

[](#i-need-to-mark-active-nodes)

There's a method for it!

```
use PK\Navigation\Node;

$navigation = new Node();
$navigation->addChild(new Node('Homepage', 'Homepage:'), 1);
$navigation->addChild(new Node('Blog:', 'Blog:'), 5);

$navigation->resolveActive(function($link) {
	return $presenter->isLinkCurrent($link);
});
```

It is always called upon the whole node tree.

#### When a node is active, I need its parent to be active too

[](#when-a-node-is-active-i-need-its-parent-to-be-active-too)

Pass `TRUE` as the second parameter.

```
$navigation->resolveActive($callback, TRUE);
```

#### I need to get an array of active nodes

[](#i-need-to-get-an-array-of-active-nodes)

```
use PK\Navigation\NodeView;

$navigation->renderActiveNodes(new NodeView());
```

Method renders the node upon which the method is called to the given view object and all the active children including nested ones into the property `$children`.

### Not everyone can see all the navigation items

[](#not-everyone-can-see-all-the-navigation-items)

You can either restrict access based on the user role or on the user permissions. Be aware, you can not combine both ways.

```
use PK\Navigation\Node;
use PK\Navigation\NodeView;

$roleRestricted = new Node('the Jedi Temple', 'Entrance:');
$roleRestriected->restrictAccess('jedi'); // only jedi can access the jedi temple
$roleRestriected->render(new NodeView(), function($role) {
	return $role === 'jedi';
});

$permissionsRestricted = new Node('Abydos', 'Stargate:abydos');
$permissionsRestricted->restrictPermissions('startgate', 'access'); // only people with access to a stargate can travel to Abydos
$permissionsRestricted->render(new NodeView(), function($resource, $privilege) {
	return $resource === 'stargate' && $privilege === 'access';
});
```

Passing the callback to the render method is critical, it determines whether a node is rendered or not. If the callback returns `TRUE` the node is rendered, otherwise it is not.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4877d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2a3125054c7663536323a7d30369a2bd71b89943f508785c2c7b21906559917?d=identicon)[pavelkucera](/maintainers/pavelkucera)

---

Top Contributors

[![pavelkucera](https://avatars.githubusercontent.com/u/332800?v=4)](https://github.com/pavelkucera "pavelkucera (10 commits)")

---

Tags

nettecontrolnavigationbreadcrumbs

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pavelkucera-navigation/health.svg)

```
[![Health](https://phpackages.com/badges/pavelkucera-navigation/health.svg)](https://phpackages.com/packages/pavelkucera-navigation)
```

###  Alternatives

[contributte/menu-control

Menu control for Nette framework

29108.6k1](/packages/contributte-menu-control)[carrooi/nette-menu

Menu control for Nette framework

2950.0k1](/packages/carrooi-nette-menu)[extpoint/yii2-megamenu

Configurable site map with auto generate page title, breadcrumbs and navigation

3310.9k](/packages/extpoint-yii2-megamenu)[geeklabs/ci4-breadcrumbs

Breadcrumb navigation for CodeIgniter 4

2813.5k](/packages/geeklabs-ci4-breadcrumbs)[naucon/breadcrumbs

The breadcrumb package helps to integrate a common breadcrumb navigation into a web application. The package includes two components: A breadcrumbs class to add breadcrumb elements and a breadcrumbs helper to render html markup in php or smarty templates.

1225.4k](/packages/naucon-breadcrumbs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
