Commit 4fc7736e authored by Robert Lyon's avatar Robert Lyon
Browse files

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



To handle the fact that blog blocks have more than one blogpost and
therefore more than one comment link I've passed the artefact id and
block id in together and appended a '0'
to the front of the id so that the artefact id + block id does not
clash with another block of the same id.

Change-Id: Iddd4dab7afe70e8926a8556cdb55ea8d4dceda06
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent e30c2b8b
......@@ -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}
Supports Markdown
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