Commit 694cc595 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Rewrite blog list to use artefactchooser paginator

parent 6b8e261d
......@@ -78,9 +78,10 @@ define('SECTION_PAGE', 'index');
ArtefactTypeBlog::build_blog_list_html($blogs);
$smarty = smarty();
$smarty = smarty(array('paginator'));
$smarty->assign_by_ref('blogs', $blogs);
$smarty->assign('PAGEHEADING', hsc(get_string("myblogs", "artefact.blog")));
$smarty->assign('INLINEJAVASCRIPT', 'addLoadEvent(function() {' . $blogs->pagination_js . '});');
$smarty->display('artefact:blog:index.tpl');
?>
......@@ -288,11 +288,13 @@ class ArtefactTypeBlog extends ArtefactType {
public static function build_blog_list_html(&$blogs) {
$smarty = smarty_core();
$smarty->assign_by_ref('blogs', $blogs);
$blogs->html = $smarty->fetch('artefact:blog:bloglist.tpl');
$blogs->pagination = build_pagination(array(
$blogs->tablerows = $smarty->fetch('artefact:blog:bloglist.tpl');
$pagination = build_pagination(array(
'id' => 'bloglist_pagination',
'class' => 'center',
'url' => get_config('wwwroot') . 'artefact/blog/index.php',
'jsonscript' => 'artefact/blog/index.json.php',
'datatable' => 'bloglist',
'count' => $blogs->count,
'limit' => $blogs->limit,
'offset' => $blogs->offset,
......@@ -304,6 +306,8 @@ class ArtefactTypeBlog extends ArtefactType {
'resultcounttextsingular' => get_string('blog', 'artefact.blog'),
'resultcounttextplural' => get_string('blogs', 'artefact.blog'),
));
$blogs->pagination = $pagination['html'];
$blogs->pagination_js = $pagination['javascript'];
}
/**
......
{if empty($blogs->data)}
<div>{str tag=youhavenoblogs section=artefact.blog}</div>
{else}
<table class="tablerenderer fullwidth">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{foreach from=$blogs->data item=blog}
<tr class="{cycle name=rows values=r1,r0}">
<td>
......@@ -22,6 +11,3 @@
</td>
</tr>
{/foreach}
</tbody>
</table>
{/if}
......@@ -3,8 +3,17 @@
<div class="rbuttons">
<a class="btn-add" href="{$WWWROOT}artefact/blog/new/">{str section="artefact.blog" tag="addblog"}</a>
</div>
<div id="bloglist">
{$blogs->html}
</div>
{if $blogs->data}{$blogs->pagination.html}{/if}
{if empty($blogs->data)}
<div>{str tag=youhavenoblogs section=artefact.blog}</div>
{else}
<table id="bloglist" class="tablerenderer fullwidth">
<thead>
<tr><th></th><th></th></tr>
</thead>
<tbody>
{$blogs->tablerows}
</tbody>
</table>
{$blogs->pagination}
{/if}
{include file="footer.tpl"}
......@@ -80,8 +80,8 @@ var Paginator = function(id, datatable, script, extradata) {
// Update the result count
var results = getFirstElementByTagAndClassName('div', 'results', self.id);
if (results) {
results.innerHTML = data['data']['results'];
if (results && data.data.results) {
results.innerHTML = data.data.results;
}
}
......
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