public function getPostsByTag($tagId, $current, $count = 10) { $where = 'id IN (SELECT re.article_id FROM ar_article_tag re WHERE re.tag_id=:tag)'; $params = [':tag' => $tagId]; $total = $this->getPostCount($where, $params); list($total, $offset, $count, $page_nums, $current) = Tools::createPageInfo($total, $count, $current); $sql = "SELECT * FROM `ar_article` WHERE {$where} ORDER BY `publish_date` DESC LIMIT {$offset}, {$count}"; $stat = $this->getPDO()->prepare($sql); $stat->execute($params); return ['data' => $stat->fetchAll(\PDO::FETCH_ASSOC), 'page' => ['total' => $total, 'offset' => $offset, 'count' => $count, 'page_nums' => $page_nums, 'current' => $current]]; }
<a href="category/<?php echo $cat['id']; ?> .html"><?php echo $cat['name']; ?> </a> <?php } ?> </h4> <div class="am-g"> <div class="am-u-sm-12"> <?php echo \Demo\Libraries\Tools::blogSummary($post['model'] == 'markdown' ? $parsedown->parse($post['content']) : $post['content'], 400); ?> </div> </div> </article> <hr class="am-article-divider blog-hr"> <?php } ?> <ul class="am-pagination blog-pagination"> <?php if ($page['current'] > 1) { ?>