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,39 +33,35 @@ 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:
3) Add to SiteController (or configure via `$route` param in `urlManager`):
76
+
**Setup Page Action**
77
+
78
+
Add to SiteController (or configure via `$route` param in `urlManager`):
79
+
76
80
```php
77
81
public function actions()
78
82
{
79
83
return [
80
84
'page' => [
81
85
'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
86
]
100
87
];
101
88
}
102
89
```
103
-
> And now you can create your own pages via admin panel.
90
+
**Now you can use this module with all available features.**
104
91
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:
92
+
## Features:
109
93
94
+
1. Markdown Editor support:
110
95
```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
-
],
96
+
'modules' => [
97
+
'cms' => [
98
+
'class' => 'yii2mod\cms\Module',
99
+
'enableMarkdown' => true,
100
+
// List of options: https://github.com/NextStepWebs/simplemde-markdown-editor#configuration
101
+
'markdownEditorOptions' => [
102
+
'showIcons' => ['code', 'table'],
121
103
],
122
-
// ...
123
104
],
124
-
// ...
125
-
];
105
+
],
126
106
```
127
107
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:
108
+
2. You can insert your own widget on the page by the following steps:
109
+
110
+
- Create the widget, for example:
111
+
112
+
```php
113
+
namespace app\widgets;
114
+
115
+
use yii\base\Widget;
116
+
117
+
class MyWidget extends Widget
118
+
{
119
+
/**
120
+
* @inheritdoc
121
+
*/
122
+
public function run()
123
+
{
124
+
parent::run();
125
+
126
+
echo 'Text from widget';
127
+
}
128
+
129
+
/**
130
+
* This function used for render the widget
131
+
*
132
+
* @return string
133
+
*/
134
+
public static function show()
135
+
{
136
+
return self::widget();
137
+
}
138
+
}
139
+
```
170
140
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:
141
+
- When you create the page via admin panel add the following code to the page content:
142
+
143
+
```
144
+
[[\app\widgets\MyWidget:show]]
145
+
```
146
+
147
+
3. You can use parameters in your page content, for example: {siteName}, {homeUrl}. For parsing this parameters you can use the `baseTemplateParams` property:
148
+
149
+
```php
150
+
public function actions()
151
+
{
152
+
return [
153
+
'page' => [
154
+
'class' => 'yii2mod\cms\actions\PageAction',
155
+
'baseTemplateParams' => [
156
+
'homeUrl' => 'your site home url',
157
+
'siteName' => Yii::$app->name
158
+
]
159
+
],
160
+
];
161
+
}
162
+
```
163
+
164
+
4. You can change comments module settings by the following code:
175
165
176
166
```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:
186
-
'baseTemplateParams' => [
187
-
'homeUrl' => 'your site home url',
188
-
'siteName' => Yii::$app->name
189
-
]
190
-
],
191
-
];
192
-
}
167
+
public function actions()
168
+
{
169
+
return [
170
+
'page' => [
171
+
'class' => 'yii2mod\cms\actions\PageAction',
172
+
'commentWidgetParams' => [
173
+
'maxLevel' => 1,
174
+
'dataProviderConfig' => [
175
+
'pagination' => [
176
+
'pageSize' => 10
177
+
],
178
+
],
179
+
]
180
+
]
181
+
];
182
+
}
193
183
```
184
+
185
+
> For detail information about comments module please visit the following [page](https://github.com/yii2mod/yii2-comments)
0 commit comments