Added pagination to tag list
This commit is contained in:
parent
18bfd6605d
commit
532fe9f7e6
4 changed files with 22 additions and 3 deletions
|
@ -31,6 +31,7 @@ paths[privacy]=./data/privacy.md
|
|||
usersPerPage=8
|
||||
postsPerPage=20
|
||||
logsPerPage=250
|
||||
tagsPerPage=100
|
||||
thumbWidth=150
|
||||
thumbHeight=150
|
||||
thumbStyle=outside
|
||||
|
|
|
@ -3,17 +3,25 @@ class TagController
|
|||
{
|
||||
/**
|
||||
* @route /tags
|
||||
* @route /tags/{page}
|
||||
* @route /tags/{filter}
|
||||
* @route /tags/{filter}/{page}
|
||||
* @validate filter [a-zA-Z\32:,_-]+
|
||||
* @validate page \d*
|
||||
*/
|
||||
public function listAction($filter = null)
|
||||
public function listAction($filter = null, $page = 1)
|
||||
{
|
||||
$this->context->viewName = 'tag-list-wrapper';
|
||||
|
||||
PrivilegesHelper::confirmWithException(Privilege::ListTags);
|
||||
$suppliedFilter = $filter ?: InputHelper::get('filter') ?: 'order:alpha,asc';
|
||||
$page = max(1, intval($page));
|
||||
$tagsPerPage = intval($this->config->browsing->tagsPerPage);
|
||||
|
||||
$tags = TagSearchService::getEntitiesRows($suppliedFilter, null, null);
|
||||
$tags = TagSearchService::getEntitiesRows($suppliedFilter, $tagsPerPage, $page);
|
||||
$tagCount = TagSearchService::getEntityCount($suppliedFilter);
|
||||
$pageCount = ceil($tagCount / $tagsPerPage);
|
||||
$page = min($pageCount, $page);
|
||||
$this->context->filter = $suppliedFilter;
|
||||
$this->context->transport->tags = $tags;
|
||||
|
||||
|
@ -23,6 +31,14 @@ class TagController
|
|||
return ['name' => $tag['name'], 'count' => $tag['post_count']];
|
||||
}, $this->context->transport->tags));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->context->transport->paginator = new StdClass;
|
||||
$this->context->transport->paginator->page = $page;
|
||||
$this->context->transport->paginator->pageCount = $pageCount;
|
||||
$this->context->transport->paginator->entityCount = $tagCount;
|
||||
$this->context->transport->paginator->entities = $tags;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,7 +78,7 @@ class TagSearchService extends AbstractSearchService
|
|||
break;
|
||||
|
||||
case 'alpha':
|
||||
$sqlQuery->orderBy('name');
|
||||
$sqlQuery->orderBy('tag.name');
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,4 +45,6 @@
|
|||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?php $this->renderFile('paginator') ?>
|
||||
<?php endif ?>
|
||||
|
|
Loading…
Reference in a new issue