You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -28,36 +33,30 @@ to the require section of your composer.json.
28
33
29
34
CONFIGURATION
30
35
------------
31
-
> If you use this extension separate from the [base template](https://github.com/yii2mod/base), then you need execute migration by the following command:
36
+
37
+
**Database Migrations**
38
+
39
+
Before usage this extension, we'll also need to prepare the database.
1) To use this extension first you need to configure the [comments extension](https://github.com/yii2mod/yii2-comments), after that you have to configure the main config in your application:
46
+
**Module Setup**
47
+
48
+
To access the module, you need to configure the modules array in your application configuration:
49
+
37
50
```php
38
51
'modules' => [
39
-
'admin' => [
40
-
'controllerMap' => [
41
-
'cms' => 'yii2mod\cms\controllers\CmsController',
42
-
// Also you can override some controller properties in following way:
2) Add new Rule class to the `urlManager` array in your application configuration by the following code:
@@ -79,115 +78,80 @@ public function actions()
79
78
return [
80
79
'page' => [
81
80
'class' => 'yii2mod\cms\actions\PageAction',
82
-
// Also you can override some action properties in following way:
83
-
'layout' => 'your custom layout',
84
-
'viewPath' => 'your custom view file',
85
-
// You can set parameters that you want to parse before the page is loaded, for example:
86
-
'baseTemplateParams' => [
87
-
'homeUrl' => Yii::$app->homeUrl,
88
-
'siteName' => Yii::$app->name
89
-
],
90
-
// some comment widget params
91
-
'commentWidgetParams' => [
92
-
'maxLevel' => 1,
93
-
'dataProviderConfig' => [
94
-
'pagination' => [
95
-
'pageSize' => 5
96
-
],
97
-
],
98
-
]
99
81
]
100
82
];
101
83
}
102
84
```
103
85
> And now you can create your own pages via admin panel.
104
86
105
-
## Internationalization
106
-
107
-
All text and messages introduced in this extension are translatable under category 'yii2mod.cms'.
108
-
You may use translations provided within this extension, using following application configuration:
87
+
## Features:
109
88
89
+
1. Markdown Editor support:
110
90
```php
111
-
return [
112
-
'components' => [
113
-
'i18n' => [
114
-
'translations' => [
115
-
'yii2mod.cms' => [
116
-
'class' => 'yii\i18n\PhpMessageSource',
117
-
'basePath' => '@yii2mod/cms/messages',
118
-
],
119
-
// ...
120
-
],
91
+
'modules' => [
92
+
'cms' => [
93
+
'class' => 'yii2mod\cms\Module',
94
+
'enableMarkdown' => true,
95
+
// List of options: https://github.com/NextStepWebs/simplemde-markdown-editor#configuration
96
+
'markdownEditorOptions' => [
97
+
'showIcons' => ['code', 'table'],
121
98
],
122
-
// ...
123
99
],
124
-
// ...
125
-
];
100
+
],
126
101
```
127
102
128
-
##Additional features:
129
-
130
-
1. You can insert your own widget on the page by the following steps:
131
-
* Create the widget, for example:
132
-
133
-
```php
134
-
<?php
135
-
136
-
namespace app\widgets;
137
-
138
-
use yii\base\Widget;
139
-
140
-
/**
141
-
* Class MyWidget
142
-
* @package app\widgets
143
-
*/
144
-
class MyWidget extends Widget
145
-
{
146
-
/**
147
-
* @inheritdoc
148
-
*/
149
-
public function run()
150
-
{
151
-
parent::run();
152
-
153
-
echo 'Text from widget';
154
-
}
155
-
156
-
/**
157
-
* This function used for render the widget in the cms pages
158
-
*
159
-
* @return string
160
-
*/
161
-
public static function show()
162
-
{
163
-
return self::widget([
164
-
// additional params
165
-
]);
166
-
}
167
-
}
168
-
```
169
-
* When you create the page via admin panel add the following code to the page content:
103
+
2. You can insert your own widget on the page by the following steps:
104
+
105
+
- Create the widget, for example:
106
+
107
+
```php
108
+
namespace app\widgets;
109
+
110
+
use yii\base\Widget;
111
+
112
+
class MyWidget extends Widget
113
+
{
114
+
/**
115
+
* @inheritdoc
116
+
*/
117
+
public function run()
118
+
{
119
+
parent::run();
120
+
121
+
echo 'Text from widget';
122
+
}
123
+
124
+
/**
125
+
* This function used for render the widget
126
+
*
127
+
* @return string
128
+
*/
129
+
public static function show()
130
+
{
131
+
return self::widget();
132
+
}
133
+
}
134
+
```
135
+
136
+
- When you create the page via admin panel add the following code to the page content:
170
137
171
-
```
172
-
[[\app\widgets\MyWidget:show]]
173
-
```
174
-
2. You can use parameters in your page content, for example: {siteName}, {homeUrl}. For parsing this parameters you can use the `baseTemplateParams` property:
138
+
```
139
+
[[\app\widgets\MyWidget:show]]
140
+
```
141
+
142
+
3. You can use parameters in your page content, for example: {siteName}, {homeUrl}. For parsing this parameters you can use the `baseTemplateParams` property:
175
143
176
144
```php
177
-
/**
178
-
* @return array
179
-
*/
180
-
public function actions()
181
-
{
182
-
return [
183
-
'page' => [
184
-
'class' => 'yii2mod\cms\actions\PageAction',
185
-
// You can set parameters that you want to parse before the page is loaded, for example:
0 commit comments