countByMonth() public method

Return an array of the most $num recent posts, including URL and title
public countByMonth ( string $year, string $month ) : integer
$year string
$month string
return integer
示例#1
0
 /**
  * List all of the blog posts for a given year/month
  *
  * @route blog/{year}/{month}
  * @param string $year
  * @param string $month
  */
 public function listMonth(string $year, string $month)
 {
     $count = $this->blog->countByMonth($year, $month);
     list($offset, $limit) = $this->getOffsetAndLimit();
     $blogRoll = $this->blog->listByMonth($year, $month, $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;
     }
     $dt = new \DateTime("{$year}-{$month}-01");
     $page = (int) \ceil($offset / ($limit ?? 1)) + 1;
     $args = ['blogroll' => $blogRoll, 'mathjax' => $mathJAX, 'pageTitle' => \__('Blog Posts in %s %s (Page %d)', 'default', Util::noHTML($dt->format('F')), Util::noHTML($dt->format('Y')), $page), 'pagination' => ['base' => \Airship\LensFunctions\cabin_url() . 'blog/' . $year . '/' . $month, 'suffix' => '/?page=', 'count' => $count, 'page' => $page, 'per_page' => $limit]];
     $this->config('blog.cachelists') ? $this->stasis('blog/list', $args) : $this->lens('blog/list', $args);
 }