Base content management system for Yii Framework 2.0
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yii2mod/yii2-cms "*"
or add
"yii2mod/yii2-cms": "*"
to the require section of your composer.json.
If you use this extension separate from the base template, then you need execute migration by the following command:
php yii migrate --migrationPath=@vendor/yii2mod/yii2-cms/migrations
NOTE: comments extension used in 1.0.5 release and above, if you are using a previous version of this extension, you don't need to install comments extension.
- To use this extension first you need to configure the comments extension, after that you have to configure the main config in your application:
'modules' => [
'admin' => [
'controllerMap' => [
'cms' => 'yii2mod\cms\controllers\CmsController'
// You can set your template files
// 'layout' => '@app/modules/backend/views/layouts/main',
// 'viewPath' => '@app/modules/backend/views/cms/',
],
],
],
You can then access to management section through the following URL:
- Add new Rule class to the
urlManager
array in your application configuration by the following code:
'components' => [
'urlManager' => [
'rules' => [
['class' => 'yii2mod\cms\components\PageUrlRule'],
]
],
],
- Add to SiteController (or configure via
$route
param inurlManager
):
/**
* @return array
*/
public function actions()
{
return [
'page' => [
'class' => 'yii2mod\cms\actions\PageAction',
// You can set your template files
'view' => '@app/views/site/page'
],
];
}
And now you can create your own pages via the admin panel, and access them via the
url
of each page.
Additional features:
-
You can insert your own widget on the page by the following steps:
- Create the widget and add the static function. For example:
public static function insertList() { return self::widget([ //your params ]); }
-
When you create the page via admin panel add the following code to the content:
\app\widgets\MyWidget:list() // call the function insertList placed in MyWidget class