2017 © Pedro Peláez
 

yii2-extension yii2-cms-module

Yii2 CMS & Router Module

image

webkadabra/yii2-cms-module

Yii2 CMS & Router Module

  • Sunday, July 15, 2018
  • by Webkadabra
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-cms-module

A CMS & routing module for Yii 2 applications., (*1)

Features:, (*2)

  • content version history & sandbox mode
  • multilingual support
  • handles routing on top of built-in urlManager
  • manage URL redirects
  • sitemap support

Installation via Composer

You can install package with a command:, (*3)

composer require webkadabra/yii2-cms-module, (*4)

Setup

**Note***: even though this module will run on most of MySQL versions, automated migrations require MySql >= 5.6., (*5)

Configuration

Add cms component to your main application configuration (e.g. config/main.php or frontend/config/main.php, depending on your application structure):, (*6)

// ...
'components' => [
        // ...
        'cms' =>[
            'class' => 'webkadabra\yii\modules\cms\components\CmsRouter',
        ],
        // ...
],
// ...

Add cms component to bootstrap property at your main application config (usually, the same file as in previous step):, (*7)

// ...
    'bootstrap' => ['log',  'cms', /* ... other conponents ... */],
],
// ...

Add cms-web module to your main (web) application:, (*8)

// ...
'modules' => [
        // ...
        'cms-web' => 'webkadabra\yii\modules\cms\Module',
        // ...
],
// ...

Add cms module to your admin or backend application (it can be the same application config):, (*9)

// ...
'modules' => [
        // ...
        'cms' => [
            'class' => 'webkadabra\yii\modules\cms\AdminModule',
            'availableControllerRoutes' => [
                'site' => [
                    'label' => 'Global',
                    'actions' => [
                        'index' => 'Home page',
                        'contact' => 'Contact page',
                        'page' => [
                            'label' => 'Static page',
                            'params' => [
                                ['view' => 'File name'],
                            ],
                            #'params'=>['id', 'dummy'], // For multiple params
                        ],
                    ],
                ],
                'rss'=>[
                    'label' => 'RSS feeds controller',
                    'actions'=>[
                        'view'=>[
                            'label'=>'Display feed',
                            'params'=>['id'], // Required or available action params
                        ],
                    ],
                    'store' => [
                        'label' => 'Store',
                        'actions' => [
                            'index' => 'Store front page',
                            'good' => [
                                'label' => 'Offer page',
                                'params' => [
                                    ['alias' => 'Offer code (alias or SKU)'],
                                ],
                            ],
                            'listCategory' => [
                                'label' => 'Offers in a category',
                                'params' => [
                                    ['alias' => 'Category code (alias)'],
                                ],
                            ],
                            'promotion' => [
                                'label' => 'Promo page',
                                'params' => [
                                    ['promoid' => 'Promotion ID'],
                                    ['promoName' => 'Promotion name'],
                                ],
                            ],
                        ],
                    ],
                ]
            ],
        ],
        // ...
],
// ...

Make sure you have create folder where module will look for template files. By default, it's @app/views/cms-templates, (*10)

(optional) Add module migrations folder to your console application config file (or main config file, if you're not using advanced application structure):, (*11)

// ...
'controllerMap' => [
    'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationPath' => [
                '@app/migrations',
                'vendor/webkadabra/yii2-cms-module/migrations',
            ],
        ],
],
// ...

... and then run php yii migrate command. If you choose not to add module's migrations path to your config, you can setup database by running migrations directly:, (*12)

$ php yii migrate --migrationPath=@vendor/webkadabra/yii2-cms-module/migrations, (*13)

NOTICE: you will have to run this command every time there is a change in modules' migrations., (*14)

Finally, for the best admin experience, make sure your admin layout files do output blocks actions, links and footer. You can do it by adding this code to your layouts:, (*15)

    // ...
    if (isset($this->blocks['actions'])) {
        echo $this->blocks['actions']; 
    }
    if (isset($this->blocks['links'])) {
        echo $this->blocks['links']; 
    }
    if (isset($this->blocks['footer'])) {
        echo $this->blocks['footer']; 
    }
    // ...

Multilingual websites

This module will automatically start working in multilingual mode with omgdef\multilingual extension, (*16)

Usage

Template files

Each PHP template must have a block of comments at the beginning of a file for it to be used in CMS module. Example of such code block:, (*17)

<?php
/**
 * Template: Catalog Category
 * Blocks: Content, Image link, Footer
 *
 * @var $Category common\models\ShopCatalogCategory
 */
 ?>

<img src="<?php echo $this->context->printBlock('Image link'); ?>" />
<?php echo $this->context->printBlock('Content'); ?>
<?php echo $this->context->printBlock('Footer'); ?>

TODO

  • Template management

Support project development

Hey guys, I'm disabled developer that can't hold a job in the office. If you can - support my opensource, I gotta keep the cats fed. Thanks!, (*18)

Bitcoin address (I can not accept Paypal in my country):, (*19)

1Ceg8xdYpFmyPgeqqWDBBXVztcuNsWTMpq, (*20)

  • Sergii

Thanks, pull requests and donations are welcome!, (*21)

The Versions

15/07 2018

dev-master

9999999-dev

Yii2 CMS & Router Module

  Sources   Download

MIT

The Requires

 

yii2 documentation module cms router