mbtdr3ev - 4天前注册会员;
3n44fZgo - 23天前注册会员;
73n5lsCR - 37天前注册会员;
NaZ2pUfG - 46天前注册会员;
bwpKIZwD - 95天前注册会员;
加入我们(62 )

typecho同分类下的文章上下页

functions.php

// 同分类下的上下页
function prev_post($archive)
{
    $db = Typecho_Db::get();

    $thiaMid  = $db->fetchRow($db->select()
            ->from('table.relationships')
            ->where('table.relationships.cid = ?', $archive->cid)
            ->limit(1));

    $content = $db->fetchRow($db->select()
        ->from('table.contents')
        ->join('table.relationships', 'table.contents.cid = table.relationships.cid',Typecho_Db::LEFT_JOIN)
        ->where('table.contents.created < ?', $archive->created)
        ->where('table.contents.status = ?', 'publish')
        ->where('table.contents.type = ?', $archive->type)
        ->where('table.contents.password IS NULL')
        ->order('table.contents.created', Typecho_Db::SORT_DESC)
        ->limit(1));

    if ($content['mid']==$thiaMid['mid'])
    {
        if($content){
            $content = Typecho_Widget::widget('Widget_Abstract_Contents')->filter($content);
        echo '<div class="nav-previous"><a href="' . $content['permalink'] . '" rel="prev"><span class="meta-nav">上一篇: </span> <span class="post-title">' . $content['title'] . '</span></a></div>';
        }else{
            echo "";
        }

    }
    else
    {
        echo '';
    }

}

function next_post($archive)
{
    $db = Typecho_Db::get();
    $thiaMid  = $db->fetchRow($db->select()
            ->from('table.relationships')
            ->where('table.relationships.cid = ?', $archive->cid)
            ->limit(1));
    $content = $db->fetchRow($db->select()
            ->from('table.contents')
            ->join('table.relationships', 'table.contents.cid = table.relationships.cid',Typecho_Db::LEFT_JOIN)
            ->where('table.contents.created > ? AND table.contents.created < ?', $archive->created, Helper::options()->gmtTime)
            ->where('table.contents.status = ?', 'publish')
            ->where('table.contents.type = ?', $archive->type)
            ->where('table.contents.password IS NULL')
            ->order('table.contents.created', Typecho_Db::SORT_ASC)
            ->limit(1));
    if ($content['mid']==$thiaMid['mid'])
    {
        if($content){
            $content = Typecho_Widget::widget('Widget_Abstract_Contents')->filter($content);
            echo '<div class="nav-next"><a href="' . $content['permalink'] . '" rel="next"><span class="meta-nav">下一篇: </span> <span class="post-title">' . $content['title'] . '</span></a></div>';
        }else{
            echo "";
        }
    }
    else
    {
        echo '';
    }
}

声明:本站原创文章文字版权归本站所有,转载务必注明作者和出处;本站转载文章仅仅代表原作者观点,不代表本站立场,图文版权归原作者所有。如有侵权,请联系我们删除。