Skip to content

Commit

Permalink
Add comments while editing news post
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Jul 7, 2021
1 parent 0792a75 commit d6c6bd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/controllers/News/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace BNETDocs\Controllers\News;

use \BNETDocs\Libraries\Authentication;
use \BNETDocs\Libraries\Comment;
use \BNETDocs\Libraries\EventTypes;
use \BNETDocs\Libraries\Exceptions\NewsPostNotFoundException;
use \BNETDocs\Libraries\Logger;
Expand Down Expand Up @@ -59,6 +60,11 @@ public function &run(Router &$router, View &$view, array &$args)
} else {
$flags = $model->news_post->getOptionsBitmask();

$model->comments = Comment::getAll(
Comment::PARENT_TYPE_NEWS_POST,
$model->news_post_id
);

$model->news_categories = NewsCategory::getAll();
usort($model->news_categories, function($a, $b){
$oA = $a->getSortId();
Expand Down
3 changes: 3 additions & 0 deletions src/templates/News/Edit.phtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
namespace BNETDocs\Templates\News;
use \BNETDocs\Libraries\Comment;
use \CarlBennett\MVC\Libraries\Common;
use \CarlBennett\MVC\Libraries\Pair;
$title = 'Edit News Post';
$description = 'This page enables a user to edit a news post on the site.';
$this->opengraph->attach(new Pair('url', '/news/edit'));
$this->opengraph->attach(new Pair('type', 'article'));
$comments = $this->getContext()->comments;
$error = $this->getContext()->error;
switch ($error)
{
Expand Down Expand Up @@ -36,6 +38,7 @@ require('./header.inc.phtml'); ?>
</div>
<? }
require('./News/Form.inc.phtml');
$comment_parent_type = Comment::PARENT_TYPE_NEWS_POST; $comment_parent_id = $news_post_id; require('./Comment/Section.inc.phtml');
} else { ?>
<div class="alert alert-success">
<p class="mb-0">Your news post has been edited successfully!</p>
Expand Down

0 comments on commit d6c6bd7

Please sign in to comment.