All Projects → dmstr → Yii2 Pages Module

dmstr / Yii2 Pages Module

Application sitemap and navigation manager module for Yii 2.0 Framework

Projects that are alternatives of or similar to Yii2 Pages Module

Sitemap
Site map creation support
Stars: ✭ 59 (+96.67%)
Mutual labels:  sitemap, yii2
Heavycms
HeavyDots CMS - Open source CMS based on Yii2
Stars: ✭ 12 (-60%)
Mutual labels:  yii2
Yii2 Fullcalendar
Widget for Yii Framework 2.0 to use FullCalendar
Stars: ✭ 5 (-83.33%)
Mutual labels:  yii2
Yii2 Slack Log
Pretty Slack log target for Yii 2
Stars: ✭ 24 (-20%)
Mutual labels:  yii2
Yii2 Helpers
Collection of useful helper functions for Yii Framework 2.0
Stars: ✭ 16 (-46.67%)
Mutual labels:  yii2
Yii2 App Another
Yii 2 Another Project Template
Stars: ✭ 9 (-70%)
Mutual labels:  yii2
Rust Full Stack
Rust projects here are easy to use. There are blog posts for them also.
Stars: ✭ 745 (+2383.33%)
Mutual labels:  sitemap
Yii2 User
[ABANDONED] Flexible user registration and authentication module for Yii2
Stars: ✭ 946 (+3053.33%)
Mutual labels:  yii2
Yii2 Bx Slider
bx-slider.js wrapper for yii2.
Stars: ✭ 11 (-63.33%)
Mutual labels:  yii2
Yii2 Telegram Log
Telegram log target for Yii 2
Stars: ✭ 24 (-20%)
Mutual labels:  yii2
Graphview
Android GraphView is used to display data in graph structures.
Stars: ✭ 918 (+2960%)
Mutual labels:  tree-structure
Yii2 Google Maps Markers
Google Maps Markers Widget for Yii2
Stars: ✭ 16 (-46.67%)
Mutual labels:  yii2
Yii2 C3 Chart
Yii2 wrapper for D3-based reusable chart library
Stars: ✭ 9 (-70%)
Mutual labels:  yii2
Opensourcewebsite Org
OpenSourceWebsite (OSW) - online community managed by users using electronic voting and modifying source code
Stars: ✭ 834 (+2680%)
Mutual labels:  yii2
Yii2 Toastr
Yii2 wrapper for toastr javascript notification library
Stars: ✭ 14 (-53.33%)
Mutual labels:  yii2
Jekyll Sitemap
Jekyll plugin to silently generate a sitemaps.org compliant sitemap for your Jekyll site
Stars: ✭ 782 (+2506.67%)
Mutual labels:  sitemap
Yii2 Fotorama Widget
Fotorama image gallery widget for yii2
Stars: ✭ 18 (-40%)
Mutual labels:  yii2
Yii2 Hitable Behavior
The hit countable behavior for the Yii2 framework.
Stars: ✭ 8 (-73.33%)
Mutual labels:  yii2
Dream
编程浪子的梦博客
Stars: ✭ 29 (-3.33%)
Mutual labels:  yii2
Yii2 Elfinder
elFinder file manager for Yii 2
Stars: ✭ 21 (-30%)
Mutual labels:  yii2

Yii2 Page Manager

Latest Stable Version Total Downloads License

Application sitemap and navigation manager module for Yii 2.0 Framework

⚠️ Breaking changes in 0.14.0 and 0.18.0

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

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.

Either run

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

or add

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

to the require section of your composer.json file.

Setup

Run migrations

./yii migrate \
    --disableLookup=1 \
    [email protected]/dmstr/yii2-pages-module/migrations

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' => [
		'<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

  • 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

Navbar (eg. layouts/main)

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

  • 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

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

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

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')

Copy pages

Console config

'controllerMap'       => [
	'copy-pages' => '\dmstr\modules\pages\commands\CopyController',
]

CLI

Command: yii copy-pages/root-node --rootId --destinationLanguage

Web UI

Url: /pages/copy

RBAC permission

pages.globalAccess

Whether a user can select * (global) for a menu item.

pages_copy

Usage

  • Switch to the application language you want to copy page root nodes to -> /pages/copy
  • Select the root node you whant to copy
  • Select the target language or you can select the global domain if you have permissions to
  • Start Copy

Testing

Requirements:

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

Codeception is run via "Potemkin"-Phundament.

cd tests

Start test stack

make all

Run tests

make run-tests

Ressources

tbd


dmstr logo Built by dmstr

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].