Skip to content

Commit 6a8391e

Browse files
author
Igor Chepurnoy
committed
added 'commentWidgetParams'
1 parent d14d653 commit 6a8391e

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ public function actions()
8686
'baseTemplateParams' => [
8787
'homeUrl' => Yii::$app->homeUrl,
8888
'siteName' => Yii::$app->name
89+
],
90+
// some comment widget params
91+
'commentWidgetParams' => [
92+
'maxLevel' => 1,
93+
'dataProviderConfig' => [
94+
'pagination' => [
95+
'pageSize' => 5
96+
],
97+
],
8998
]
9099
]
91100
];

actions/PageAction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class PageAction extends Action
3535
*/
3636
public $baseTemplateParams = [];
3737

38+
/**
39+
* @var array
40+
*/
41+
public $commentWidgetParams = [];
42+
3843
/**
3944
* Initializes the object.
4045
*/
@@ -65,6 +70,7 @@ public function run()
6570

6671
return $this->controller->render($this->view, [
6772
'model' => $model,
73+
'commentWidgetParams' => $this->commentWidgetParams,
6874
]);
6975
}
7076

views/page.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
/* @var $this \yii\web\View */
44
/* @var $model \yii2mod\cms\models\CmsModel */
5+
/* @var $commentWidgetParams array */
56

7+
use yii\helpers\ArrayHelper;
68
use yii2mod\comments\widgets\Comment;
79

810
$this->params['bodyClass'] = $model->url;
@@ -14,9 +16,13 @@
1416
<h1><?php echo $model->title; ?></h1>
1517
<?php echo $model->getContent(); ?>
1618
<?php if ($model->commentAvailable): ?>
17-
<?php echo Comment::widget([
18-
'model' => $model,
19-
'relatedTo' => 'cms page: ' . $model->url,
20-
]); ?>
19+
<?php echo Comment::widget(ArrayHelper::merge(
20+
[
21+
'model' => $model,
22+
'relatedTo' => 'cms page: ' . $model->url,
23+
],
24+
$commentWidgetParams
25+
)); ?>
26+
2127
<?php endif; ?>
2228
</div>

0 commit comments

Comments
 (0)