Esempio n. 1
0
                   title=<?php 
        echo $post['term_name'];
        ?>
> <?php 
        echo $post['term_name'];
        ?>
</a>
                <a class='meta-date'></a><?php 
        echo $post['post_date'];
        ?>
</a>
            </div>
            <!-- post_meta end -->
            <div class="post_excerpt">
                <?php 
        $post['post_excerpt'] = md_to_html($post['post_excerpt']);
        ?>
                <?php 
        echo $post['post_excerpt'];
        ?>
            </div>
            <!-- post_content end -->
            <div class="post_footer">
                <a href=<?php 
        echo $post_url;
        ?>
 class="read_more"><span>全文阅读</span></a>
            </div>
        </div>

    <?php 
Esempio n. 2
-8
 /**
  * 获取单一的文章
  * @params $display 设置为true时返回转换为HTML的Markdown文档,否则为原生markdown文本
  */
 function getPostById($post_id, $display = true)
 {
     $select_query = 'post_id, post_title, post_date, post_content, term_id, post_status, post_excerpt';
     $where_query = "post_id = {$post_id} and post_status = 'publish'";
     $sql = "select {$select_query} from blog_posts where {$where_query}";
     $res = $this->db->query($sql);
     if ($this->db->affected_rows() > 0) {
         $row = $this->db->fetch_array($res);
         $row['post_title'] = htmlspecialchars($row['post_title']);
         if ($display) {
             $row['post_content'] = md_to_html($row['post_content']);
         } else {
             $row['post_content'] = htmlspecialchars($row['post_content']);
         }
         $term_name = Category_Model::getInstance()->getTermName($row['term_id']);
         $row['term_name'] = htmlspecialchars($term_name);
         $row['post_id'] = $post_id;
         return $row;
     } else {
         return null;
     }
 }