public function getBlogMenu() : array
{
$years = [];
$getYears = $this->db->run("SELECT DISTINCT\n date_part('year', published) AS blogyear,\n date_part('month', published) AS blogmonth\n FROM\n hull_blog_posts\n WHERE\n status\n AND published <= current_timestamp\n GROUP BY\n date_part('year', published),\n date_part('month', published)\n ORDER BY\n blogyear DESC,\n blogmonth ASC\n ");
if (!empty($getYears)) {
foreach ($getYears as $yr) {
$dt = new \DateTime($yr['blogyear'] . '-' . $yr['blogmonth'] . '-01');
$y = intval($yr['blogyear']);
if ($yr['blogmonth'] < 10) {
// Left-pad with a single zero
$yr['blogmonth'] = '0' . $yr['blogmonth'];
}
$years[$y][$yr['blogmonth']] = $dt->format('F');
}
}
return ['years' => $years, 'categories' => $this->getCategoryTree(), 'uncategorized' => $this->countByCategories([]), 'tags' => $this->getTagCloud()];
}