Skip to content

Commit d6c6bd7

Browse files
committed
Add comments while editing news post
1 parent 0792a75 commit d6c6bd7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/controllers/News/Edit.php

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace BNETDocs\Controllers\News;
33

44
use \BNETDocs\Libraries\Authentication;
5+
use \BNETDocs\Libraries\Comment;
56
use \BNETDocs\Libraries\EventTypes;
67
use \BNETDocs\Libraries\Exceptions\NewsPostNotFoundException;
78
use \BNETDocs\Libraries\Logger;
@@ -59,6 +60,11 @@ public function &run(Router &$router, View &$view, array &$args)
5960
} else {
6061
$flags = $model->news_post->getOptionsBitmask();
6162

63+
$model->comments = Comment::getAll(
64+
Comment::PARENT_TYPE_NEWS_POST,
65+
$model->news_post_id
66+
);
67+
6268
$model->news_categories = NewsCategory::getAll();
6369
usort($model->news_categories, function($a, $b){
6470
$oA = $a->getSortId();

src/templates/News/Edit.phtml

+3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
22
namespace BNETDocs\Templates\News;
3+
use \BNETDocs\Libraries\Comment;
34
use \CarlBennett\MVC\Libraries\Common;
45
use \CarlBennett\MVC\Libraries\Pair;
56
$title = 'Edit News Post';
67
$description = 'This page enables a user to edit a news post on the site.';
78
$this->opengraph->attach(new Pair('url', '/news/edit'));
89
$this->opengraph->attach(new Pair('type', 'article'));
10+
$comments = $this->getContext()->comments;
911
$error = $this->getContext()->error;
1012
switch ($error)
1113
{
@@ -36,6 +38,7 @@ require('./header.inc.phtml'); ?>
3638
</div>
3739
<? }
3840
require('./News/Form.inc.phtml');
41+
$comment_parent_type = Comment::PARENT_TYPE_NEWS_POST; $comment_parent_id = $news_post_id; require('./Comment/Section.inc.phtml');
3942
} else { ?>
4043
<div class="alert alert-success">
4144
<p class="mb-0">Your news post has been edited successfully!</p>

0 commit comments

Comments
 (0)