2017 © Pedro Peláez
 

yii2-extension yii2-cms

Yii2 CMS extension

image

yii2mod/yii2-cms

Yii2 CMS extension

  • Saturday, November 25, 2017
  • by disem
  • Repository
  • 9 Watchers
  • 37 Stars
  • 3,996 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 21 Forks
  • 2 Open issues
  • 22 Versions
  • 4 % Grown

The README.md

, (*1)

Yii2 CMS Extension


This module provides a web interface for content management system and includes the following features:, (*2)

Latest Stable Version Total Downloads License Build Status, (*3)

Installation

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

Either run, (*5)

php composer.phar require --prefer-dist yii2mod/yii2-cms "*"

or add, (*6)

"yii2mod/yii2-cms": "*"

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

CONFIGURATION

Database Migrations, (*8)

Before usage this extension, we'll also need to prepare the database., (*9)

$ php yii migrate --migrationPath=@vendor/yii2mod/yii2-comments/migrations
$ php yii migrate --migrationPath=@vendor/yii2mod/yii2-cms/migrations

Module Setup, (*10)

To access the module, you need to configure the modules array in your application configuration:, (*11)

'modules' => [
    'cms' => [
        'class' => 'yii2mod\cms\Module',
    ],
],

You can then access to management section through the following URL:, (*12)

http://localhost/path/to/index.php?r=/cms/manage/index, (*13)

Configure Url Manager, (*14)

You need to configure the urlManager array in your application configuration:, (*15)

 'components' => [
     'urlManager' => [
         'rules' => [
             ['class' => 'yii2mod\cms\components\PageUrlRule'],
         ]
     ],
 ],

Setup Page Action, (*16)

Add to SiteController (or configure via $route param in urlManager):, (*17)

public function actions()
{
    return [
        'page' => [
            'class' => 'yii2mod\cms\actions\PageAction',
        ]
    ];
}

Now you can use this module with all available features., (*18)

Features:

  1. By default this extension uses the froala editor for manage cms pages, you can change editor configuration by the following code:

List of options: https://www.froala.com/wysiwyg-editor/docs/options, (*19)

Configuration example: https://github.com/froala/yii2-froala-editor#usage, (*20)

'modules' => [
    'cms' => [
        'class' => 'yii2mod\cms\Module',
        'froalaEditorOptions' => [
            // your custom configuration
            'clientPlugins' => [
            ],
            'clientOptions' => [
            ],
            'excludedPlugins' => [
            ],
        ],
    ],
],
  1. Markdown Editor support:
'modules' => [
    'cms' => [
        'class' => 'yii2mod\cms\Module',
        'enableMarkdown' => true,
        // List of options: https://github.com/NextStepWebs/simplemde-markdown-editor#configuration
        'markdownEditorOptions' => [
            'showIcons' => ['code', 'table'],
        ],
    ],
],
  1. You can insert your own widget on the page by the following steps:
  • Create the widget, for example:
namespace app\widgets;

use yii\base\Widget;

class MyWidget extends Widget
{
   /**
    * @inheritdoc
    */
   public function run()
   {
       parent::run();

       echo 'Text from widget';
   }

   /**
    * This function used for render the widget
    *
    * @return string
    */
   public static function show()
   {
       return self::widget();
   }
}
  • When you create the page via admin panel add the following code to the page content:
 [[\app\widgets\MyWidget:show]]
  1. You can use parameters in your page content, for example: {siteName}, {homeUrl}. For parsing this parameters you can use the baseTemplateParams property:
public function actions()
{
    return [
        'page' => [
            'class' => 'yii2mod\cms\actions\PageAction',
            'baseTemplateParams' => [
               'homeUrl' => 'your site home url',
               'siteName' => Yii::$app->name
            ]
        ],
    ];
}
  1. You can change comments module settings by the following code:
public function actions()
{
    return [
        'page' => [
            'class' => 'yii2mod\cms\actions\PageAction',
            'commentWidgetParams' => [
                'maxLevel' => 1,
                'dataProviderConfig' => [
                    'pagination' => [
                        'pageSize' => 10
                    ],
                ],
            ]
        ]
    ];
}

For detail information about comments module please visit the following page, (*21)

Support us

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff., (*22)

The Versions

02/02 2016
18/09 2015

dev-dev

dev-dev

Yii2 CMS extension

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

extension yii2

18/09 2015
06/08 2015