Commit 50f944c3 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Show number of posts in blog listing


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 6272be7c
......@@ -289,8 +289,11 @@ class ArtefactTypeBlog extends ArtefactType {
public static function get_blog_list($limit, $offset) {
global $USER;
($result = get_records_sql_array("
SELECT * FROM {artefact} WHERE \"owner\" = ? AND artefacttype = 'blog'
ORDER BY title LIMIT ? OFFSET ?", array($USER->get('id'), $limit, $offset)))
SELECT b.id, b.title, b.description, COUNT(p.id) AS postcount
FROM {artefact} b LEFT JOIN {artefact} p ON (p.parent = b.id AND p.artefacttype = 'blogpost')
WHERE b.owner = ? AND b.artefacttype = 'blog'
GROUP BY b.id, b.title, b.description
ORDER BY b.title", array($USER->get('id')), $offset, $limit))
|| ($result = array());
$count = (int)get_field('artefact', 'COUNT(*)', 'owner', $USER->get('id'), 'artefacttype', 'blog');
......
......@@ -13,6 +13,7 @@
<div>{$blog->description|clean_html}</div>
</td>
<td class="right">
<a href="{$WWWROOT}artefact/blog/view/?id={$blog->id}">{$blog->postcount}</a>
<a href="{$WWWROOT}artefact/blog/settings/?id={$blog->id}" class="btn-settings">{str tag=settings}</a>
<a onClick="confirmdelete({$blog->id});" class="btn-del">{str tag=delete}</a>
<a href="{$WWWROOT}artefact/blog/post.php?blog={$blog->id}" class="btn-add">{str tag=addpost section=artefact.blog}</a>
......
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