getTag() public method

Return information about the current tag
public getTag ( string $slug ) : array
$slug string
return array
Esempio n. 1
0
 /**
  * List all of the blog posts for a given tag
  *
  * @route blog/tag/{slug}/{page}
  * @param string $slug
  * @param string $page
  */
 public function listByTag(string $slug, string $page = '')
 {
     list($offset, $limit) = $this->getOffsetAndLimit($page);
     $tag = $this->blog->getTag($slug);
     $count = $this->blog->countByTag((int) $tag['tagid']);
     $blogRoll = $this->blog->listByTag((int) $tag['tagid'], $limit, $offset);
     $mathJAX = false;
     foreach ($blogRoll as $i => $blog) {
         $blogRoll[$i] = $this->blog->getSnippet($blog);
         if (Binary::safeStrlen($blogRoll[$i]['snippet']) !== Binary::safeStrlen($blog['body'])) {
             $blogRoll[$i]['snippet'] = \rtrim($blogRoll[$i]['snippet'], "\n");
         }
         $mathJAX = $mathJAX || \strpos($blog['body'], '$$') !== false;
     }
     $args = ['blogroll' => $blogRoll, 'pageTitle' => \__('Blog Posts Tagged "%s"', 'default', Util::noHTML($tag['name'])), 'mathjax' => $mathJAX, 'pagination' => ['base' => \Airship\LensFunctions\cabin_url() . 'blog/tag/' . $slug, 'count' => $count, 'page' => (int) \ceil($offset / ($limit ?? 1)) + 1, 'per_page' => $limit]];
     $this->config('blog.cachelists') ? $this->stasis('blog/tag', $args) : $this->lens('blog/tag', $args);
 }