with(['category']) ->field('id,title,createtime,diyname,category_id') ->order("createtime", "desc") ->cache(3600 * 365) ->select(); $yearlist = []; foreach ($postlist as $k => $v) { $yearlist[date("Y", $v['createtime'])][] = ['id' => $v['id'], 'title' => $v['title'], 'url' => $v['url']]; } $this->view->assign('yearlist', $yearlist); $this->view->assign('title', '日志归档'); return $this->view->fetch('/archive'); } }