Airship\Cabin\Bridge\Blueprint\Blog::listTags PHP Method

listTags() public method

List tags (paginated, sortable).
public listTags ( integer $offset, integer $limit, string $sort = 'name', boolean $desc = false ) : array
$offset integer
$limit integer
$sort string
$desc boolean
return array
    public function listTags(int $offset, int $limit, string $sort = 'name', bool $desc = false) : array
    {
        $orderBy = $this->orderBy($sort, $desc ? 'DESC' : 'ASC', ['name', 'created']);
        $tags = $this->db->safeQuery(\Airship\queryString('blog.tags.list_all', ['orderby' => $orderBy, 'offset' => $offset, 'limit' => $limit]));
        if (empty($tags)) {
            return [];
        }
        return $tags;
    }

Usage Example

Esempio n. 1
0
 /**
  * List tags
  *
  * @route blog/tag{_page}
  * @param mixed $page
  */
 public function listTags($page = null)
 {
     list($offset, $limit) = $this->getOffsetAndLimit($page);
     list($sort, $dir) = $this->getSortArgs('name');
     $post = $this->post(new NewTagFilter());
     if (!empty($post)) {
         if ($this->blog->createTag($post)) {
             \Airship\redirect($this->airship_cabin_prefix . '/blog/tag');
         }
     }
     $this->lens('blog/tags', ['active_link' => 'bridge-link-blog-tags', 'tags' => $this->blog->listTags($offset, $limit, $sort, $dir === 'DESC'), 'sort' => $sort, 'dir' => $dir, 'pagination' => ['base' => $this->airship_cabin_prefix . '/blog/tag', 'suffix' => '/', 'extra_args' => '?sort=' . $sort . '&dir=' . $dir, 'count' => $this->blog->numTags(), 'page' => (int) \ceil($offset / ($limit ?? 1)) + 1, 'per_page' => $limit]]);
 }