Commit 5a7e9f6b authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Allowing each blogpost in blog block to show comments (Bug #1037531)"

parents ab7a0fb2 4fc7736e
......@@ -72,6 +72,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
'jsonscript' => 'artefact/blog/posts.json.php',
);
}
$configdata['blockid'] = $instance->get('id');
ArtefactTypeBlogpost::render_posts($posts, $template, $configdata, $pagination);
$smarty = smarty_core();
......
......@@ -810,11 +810,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($viewoptions['viewid']);
$artefact = artefact_instance_from_id($post->id);
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->view = $view;
$commentoptions->artefact = $artefact;
$comments = ArtefactTypeComment::get_comments($commentoptions);
$post->commentcount = isset($comments->count) ? $comments->count : 0;
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, null, false);
$post->commentcount = $commentcount;
$post->comments = $comments;
}
}
$post->ctime = format_date($post->ctime, 'strftimedaydatetime');
......
......@@ -509,7 +509,7 @@ class ArtefactTypeComment extends ArtefactType {
* or the html to render them.
*/
public function get_artefact_comments_for_view($artefact, $view, $blockid, $html = true) {
if (empty($blockid) || !is_object($artefact) || !is_object($view)) {
if (!is_object($artefact) || !is_object($view)) {
throw new MaharaException('we do not have the right information to display the comments');
}
......
......@@ -35,6 +35,24 @@
</tbody>
</table>
{/if}
{if $options.viewid && $post->allowcomments}<div class="postdetails"><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a></div>{/if}
{if $options.viewid && ($post->commentcount || $post->commentcount === 0)}
<div class="comments">
{if $post->commentcount > 0}
<a id="block_0{$post->id}{$options.blockid}" class="commentlink" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a>
{else}
{if $post->allowcomments}
<span class="nocomments">{str tag=Comments section=artefact.comment} ({$post->commentcount})</span>
{/if}
{/if}
{if $post->allowcomments}
<a class="addcomment bar-before" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=addcomment section=artefact.comment}</a>
{/if}
</div>
<div class="feedbacktablewrapper">
<div id="feedbacktable_0{$post->id}{$options.blockid}" class="feedbacktable">
{$post->comments->tablerows|safe}
</div>
</div>
{/if}
</div>
{/foreach}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment