Commit b5639b5902e17537defd8226903b7231b33c9086
1 parent
21346174
comment widget
Showing
3 changed files
with
14 additions
and
1 deletions
Show diff stats
views/artbox_comment_item.php
| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | * @var mixed $key |
| 10 | 10 | * @var int $index |
| 11 | 11 | * @var ListView $widget |
| 12 | + * @var string $display_name | |
| 12 | 13 | */ |
| 13 | 14 | ?> |
| 14 | 15 | <div class="comments-wr"> |
| ... | ... | @@ -27,8 +28,9 @@ |
| 27 | 28 | </div> |
| 28 | 29 | <div class="user_name" itemprop="author"> |
| 29 | 30 | <?php |
| 31 | + $nameField = $display_name; | |
| 30 | 32 | if (!empty($model->customer)) { |
| 31 | - echo $model->customer->username; | |
| 33 | + echo $model->customer->$nameField; | |
| 32 | 34 | } else { |
| 33 | 35 | echo $model->username . ' (' . Yii::t('artbox-comment', 'Guest') . ')'; |
| 34 | 36 | } | ... | ... |
views/artbox_comment_list.php
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | * @var Model $model |
| 16 | 16 | * @var ActiveDataProvider $comments |
| 17 | 17 | * @var View $this |
| 18 | + * @var srring $display_name | |
| 18 | 19 | */ |
| 19 | 20 | Pjax::begin(); |
| 20 | 21 | if(( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != NULL) { |
| ... | ... | @@ -25,6 +26,10 @@ |
| 25 | 26 | 'itemOptions' => $item_options, |
| 26 | 27 | 'itemView' => $item_view, |
| 27 | 28 | 'summary' => '', |
| 29 | + 'viewParams' => [ | |
| 30 | + 'display_name' => $display_name | |
| 31 | + ] | |
| 32 | + | |
| 28 | 33 | ]); |
| 29 | 34 | Pjax::end(); |
| 30 | 35 | |
| 31 | 36 | \ No newline at end of file | ... | ... |
widgets/CommentWidget.php
| ... | ... | @@ -24,6 +24,10 @@ |
| 24 | 24 | */ |
| 25 | 25 | class CommentWidget extends Widget |
| 26 | 26 | { |
| 27 | + /** | |
| 28 | + * @var string what field is displayed in the user name | |
| 29 | + */ | |
| 30 | + public $display_name = 'username'; | |
| 27 | 31 | |
| 28 | 32 | /** |
| 29 | 33 | * Model, to which comment attached |
| ... | ... | @@ -400,6 +404,8 @@ |
| 400 | 404 | 'comments' => $comments, |
| 401 | 405 | 'item_options' => $this->itemOptions, |
| 402 | 406 | 'item_view' => $this->itemView, |
| 407 | + 'display_name' => $this->display_name, | |
| 408 | + | |
| 403 | 409 | ] |
| 404 | 410 | ), |
| 405 | 411 | $list_options | ... | ... |