2017 © Pedro Peláez
 

yii2-extension yii2-pages-module

Application sitemap and navigation manager module for Yii 2.0 Framework

image

dmstr/yii2-pages-module

Application sitemap and navigation manager module for Yii 2.0 Framework

  • Wednesday, July 25, 2018
  • by schmunk
  • Repository
  • 8 Watchers
  • 24 Stars
  • 18,040 Installations
  • PHP
  • 3 Dependents
  • 1 Suggesters
  • 14 Forks
  • 4 Open issues
  • 100 Versions
  • 5 % Grown

The README.md

Yii2 Page Manager

Latest Stable Version Total Downloads License, (*1)

Application sitemap and navigation manager module for Yii 2.0 Framework, (*2)

  • :warning: Breaking changes in 0.14.0 and 0.18.0
  • :warning: copy pages is removed in versions > 2.5.0

data structure and public properties are updated and query menu items from now on via domain_id, (*3)

Requirements

  • URL manager from codemix/yii2-localeurls configured in application
  • role based access control; auth_items for every module_controller_action

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

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

or add, (*6)

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

to the require section of your composer.json file., (*7)

Setup

Run migrations, (*8)

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

Configuration

Enable module in application configuration, (*9)

// 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' => [
        '<pagePath:[a-zA-Z0-9_\-\./\+]*>/<pageSlug:[a-zA-Z0-9_\-\.]*>-<pageId:[0-9]*>.html' => 'pages/default/page',
        '<pageSlug:[a-zA-Z0-9_\-\.]*>-<pageId:[0-9]*>.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, (*10)

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

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

find a root node / leave node, (*11)

by domain_id i.e. root, (*12)

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

use for example with bootstrap Navbar, (*13)

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

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., (*14)

Traits

We use the \dmstr\activeRecordPermissions\ActiveRecordAccessTrait to have a check access behavior on active record level, (*15)

  • Owner Access
  • Read Access
  • Update Access
  • Delete Access

Anchors

available since 0.12.0-beta1, (*16)

:construction_worker: 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'}., (*17)

It is recommended to create a new entry in Tree mode., (*18)

i18n - sibling pages

Find sibling page in target language, (*19)

/**
 * 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

Requirements:, (*20)

  • docker >=1.9.1
  • docker-compose >= 1.6.2

Codeception is run via "Potemkin"-Phundament., (*21)

cd tests

Start test stack, (*22)

make all

Run tests, (*23)

make run-tests

Ressources

tbd, (*24)


dmstr logo Built by dmstr

The Versions

10/11 2016
30/08 2016
02/08 2016
01/08 2016
20/07 2016
19/07 2016
19/07 2016
12/07 2016
18/05 2016
15/05 2016

0.15.2

0.15.2.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

13/05 2016

0.15.1

0.15.1.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

11/05 2016

0.15.0

0.15.0.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

04/05 2016

0.15.0-rc1

0.15.0.0-RC1

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

04/05 2016

0.15.0-beta3

0.15.0.0-beta3

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

04/05 2016

0.15.0-beta2

0.15.0.0-beta2

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

04/05 2016

0.15.0-beta1

0.15.0.0-beta1

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

19/04 2016

0.14.5

0.14.5.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

16/04 2016

0.14.4

0.14.4.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

16/04 2016

0.14.3

0.14.3.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

16/04 2016

0.14.2

0.14.2.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

15/04 2016

0.14.1

0.14.1.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

15/04 2016

0.14.0

0.14.0.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

08/04 2016

0.13.0

0.13.0.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

23/03 2016

0.12.0-beta2

0.12.0.0-beta2

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

15/03 2016

0.12.0-beta1

0.12.0.0-beta1

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

05/02 2016

0.11.3

0.11.3.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

08/01 2016

0.11.2

0.11.2.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

08/01 2016

0.11.1

0.11.1.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

17/12 2015

0.11.0

0.11.0.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

24/11 2015

0.10.0

0.10.0.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

23/11 2015

0.9.4

0.9.4.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

20/11 2015

0.9.3

0.9.3.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

20/11 2015

0.9.2

0.9.2.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

29/10 2015

0.9.1

0.9.1.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

25/10 2015

0.9.0

0.9.0.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

18/09 2015

0.9.0-beta1

0.9.0.0-beta1

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

18/09 2015

0.8.1

0.8.1.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

17/09 2015

0.8.0

0.8.0.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap

12/09 2015

0.7.0

0.7.0.0

Application sitemap and navigation manager module for Yii 2.0 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 navigation sitemap