PHPackages                             dmstr/yii2-pages-module - 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. dmstr/yii2-pages-module

ActiveYii2-extension

dmstr/yii2-pages-module
=======================

Application sitemap and navigation manager module for Yii 2.0 Framework

2.5.12(6mo ago)3177.5k—4.2%13[2 PRs](https://github.com/dmstr/yii2-pages-module/pulls)2BSD-3-ClausePHPCI failing

Since Mar 18Pushed 6mo ago9 watchersCompare

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

READMEChangelog (10)Dependencies (15)Versions (179)Used By (2)

Yii2 Page Manager
=================

[](#yii2-page-manager)

[![Latest Stable Version](https://camo.githubusercontent.com/da52b0e36050b29abfca06160a53a8adf8c89f922d3eb88bfad9ae5467aaf098/68747470733a2f2f706f7365722e707567782e6f72672f646d7374722f796969322d70616765732d6d6f64756c652f762f737461626c652e737667)](https://packagist.org/packages/dmstr/yii2-pages-module)[![Total Downloads](https://camo.githubusercontent.com/d4cf017961f1f8d86805d42ba0470975b63a553c70c42a0e1f9631c5ce9db30f/68747470733a2f2f706f7365722e707567782e6f72672f646d7374722f796969322d70616765732d6d6f64756c652f646f776e6c6f6164732e737667)](https://packagist.org/packages/dmstr/yii2-pages-module)[![License](https://camo.githubusercontent.com/8aa655214089ece5438f6ec1e87c669cd32ee87275d34d4b2336b29ef0971f10/68747470733a2f2f706f7365722e707567782e6f72672f646d7374722f796969322d70616765732d6d6f64756c652f6c6963656e73652e737667)](https://packagist.org/packages/dmstr/yii2-pages-module)

Application sitemap and navigation manager module for Yii 2.0 Framework

- **⚠️ Breaking changes in 0.14.0 and 0.18.0**
- **⚠️ copy pages is removed in versions &gt; 2.5.0**

`data structure` and `public properties` are updated and query menu items from now on via `domain_id`

Requirements
------------

[](#requirements)

- URL manager from [codemix/yii2-localeurls](https://github.com/codemix/yii2-localeurls) configured in application
- role based access control; `auth_items` for every `module_controller_action`

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require dmstr/yii2-pages-module "*"

```

or add

```
"dmstr/yii2-pages-module": "*"

```

to the require section of your `composer.json` file.

Setup
-----

[](#setup)

Run migrations

```
./yii migrate \
    --disableLookup=1 \
    --migrationPath=@vendor/dmstr/yii2-pages-module/migrations

```

Configuration
-------------

[](#configuration)

Enable module in application configuration

```
// module configuration
'pages' => [
	'class' => 'dmstr\modules\pages\Module',
	'layout' => '@admin-views/layouts/main',
	'roles' => ['Admin', 'Editor'],
	'defaultPageLayout' => '@app/modules/frontend/layouts/main',
	'availableRoutes' => [
		'site/index' => 'Index Route',
	],
	'availableViews' => [
		'@app/views/site/index.php' => 'Index View',
	],
],

// if used want a url suffix, e.g. '.html', add Url rules for that
'urlManager' => [
	...
	'rules' => [
		'/-.html' => 'pages/default/page',
		'-.html' => 'pages/default/page',
	],
	...
],

// register frontend asset for hiding pages via CookieButton
'on '. \yii\web\Application::EVENT_BEFORE_ACTION => function () {
    \dmstr\modules\pages\assets\PagesFrontendAsset::register(Yii::$app->controller->view);
},

```

Use settings module to configure additional controllers

- Add one controller route per line to section `pages`, key `availableRoutes`

### Settings

[](#settings)

- `pages.availableRoutes` - routes per access\_domain (for non-admin users)
- `pages.availableViews` - views per access\_domain (for non-admin users)
- `pages.availableGlobalRoutes` - global routes (for admin users)
- `pages.availableGlobalViews` - global views(for admin users)

Usage
-----

[](#usage)

#### Navbar (eg. `layouts/main`)

[](#navbar-eg-layoutsmain)

*find a root node / leave node*

by `domain_id` i.e. `root`

```
$menuItems = \dmstr\modules\pages\models\Tree::getMenuItems('root');

```

*use for example with bootstrap Navbar*

```
    echo yii\bootstrap\Nav::widget(
        [
            'options'         => ['class' => 'navbar-nav navbar-right'],
            'activateItems'   => false,
            'encodeLabels'    => false,
            'activateParents' => true,
            'items'           => Tree::getMenuItems('root'),
        ]
    );

```

#### Backend

[](#backend)

- visit `/pages` to create a root-node for your current application language.
- click the *tree* icon
- enter `name identifier (no spaces and special chars)` as *Domain ID* and *Menu name* and save
- create child node
- assign name, title, language and route/view
- save

Now you should be able to see the page in your `Nav` widget in the frontend of your application.

#### Traits

[](#traits)

We use the `\dmstr\activeRecordPermissions\ActiveRecordAccessTrait` to have a check access behavior on active record level

- Owner Access
- Read Access
- Update Access
- Delete Access

#### Anchors

[](#anchors)

*available since 0.12.0-beta1*

👷 A workaround for creating anchor links is to define a route, like `/en/mysite-2` in the settings module. On a node you can attach an anchor by using *Advanced URL settings*, with `{'#':'myanchor'}`.

It is recommended to create a new entry in *Tree* mode.

#### i18n - sibling pages

[](#i18n---sibling-pages)

Find sibling page in target language

```
/**
 * Find the sibling page in target language if exists
 *
 * @param string $targetLanguage
 * @param integer $sourceId
 * @param string $route
 *
 * @return Tree|null
 * @throws \yii\console\Exception
 */
public function sibling($targetLanguage, $sourceId = null, $route = self::DEFAULT_PAGE_ROUTE);

Example 1:
---

// page id 12 is a node in language 'en'
$sourcePage = Tree::findOne(12);

// returns corresponding page object in language 'de' or null if not exists
$targetPage = $sourcePage->sibling('de');

Example 2:
---

// find by params
$targetPage = (new Tree())->sibling('de', 12, '/pages/default/page')

```

Testing
-------

[](#testing)

Requirements:

- docker &gt;=1.9.1
- docker-compose &gt;= 1.6.2

Codeception is run via "Potemkin"-Phundament.

```
cd tests

```

Start test stack

```
make all

```

Run tests

```
make run-tests

```

Changelog
---------

[](#changelog)

2.5.10

- Removed localized root node message
- Updated kartik-v/yii2-tree-manager requirement to ^1.1.2
- Update Tree model to support new child\_allowed attribute (since kartik-v/yii2-tree-manager 1.0.9)
- Improved permission check for page nodes so allowed child nodes in not allowed parents do not show up

### [![dmstr logo](https://camo.githubusercontent.com/4a62a35a7eb620fd4540cbaa6712caa42674aa6619344ec3e37460aa1225bd01/687474703a2f2f742e7068756e64616d656e742e636f6d2f646d7374722d31362d63726f707065642e706e67)](https://camo.githubusercontent.com/4a62a35a7eb620fd4540cbaa6712caa42674aa6619344ec3e37460aa1225bd01/687474703a2f2f742e7068756e64616d656e742e636f6d2f646d7374722d31362d63726f707065642e706e67) Built by [dmstr](http://diemeisterei.de)

[](#-built-by-dmstr)

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance66

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 64.5% 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

Every ~24 days

Recently: every ~137 days

Total

159

Last Release

203d ago

Major Versions

0.23.1 → 2.0.0-beta22018-04-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b4ab2b6685ec71887908ec8cff261a16cd5bb24c69bb8ab52840e220f175f9d?d=identicon)[schmunk](/maintainers/schmunk)

---

Top Contributors

[![schmunk42](https://avatars.githubusercontent.com/u/649031?v=4)](https://github.com/schmunk42 "schmunk42 (213 commits)")[![eluhr](https://avatars.githubusercontent.com/u/13000805?v=4)](https://github.com/eluhr "eluhr (64 commits)")[![handcode](https://avatars.githubusercontent.com/u/825574?v=4)](https://github.com/handcode "handcode (41 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (4 commits)")[![gbisurgi](https://avatars.githubusercontent.com/u/18024942?v=4)](https://github.com/gbisurgi "gbisurgi (4 commits)")[![marc7000](https://avatars.githubusercontent.com/u/1118837?v=4)](https://github.com/marc7000 "marc7000 (3 commits)")[![pmeyer0501](https://avatars.githubusercontent.com/u/177620773?v=4)](https://github.com/pmeyer0501 "pmeyer0501 (1 commits)")

---

Tags

dmstrsitemaptree-structureyii2yii2extensionSitemapnavigation

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/dmstr-yii2-pages-module/health.svg)

```
[![Health](https://phpackages.com/badges/dmstr-yii2-pages-module/health.svg)](https://phpackages.com/packages/dmstr-yii2-pages-module)
```

###  Alternatives

[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)[dmstr/yii2-backend-module

Admin Dashboard

1972.4k3](/packages/dmstr-yii2-backend-module)[mrssoft/yii2-sitemap

Yii2 sitemap extension

1123.9k1](/packages/mrssoft-yii2-sitemap)

PHPackages © 2026

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