TP3.2實現上下篇切換

來源:互聯網
上載者:User
要實現上一篇跟下一篇,需要傳取一個主索引值,我們拿新聞舉栗子,首先是新聞列表,我點擊列表會進入內容頁,所以 我在點新聞列表的時候:

前端頁面:


<span>{$v.a_content}</span><a href="{$v.a_writer}?id={$v.a_id}">閱讀詳細</a></p></p></section>

這樣就取到主鍵了;然後進入內容頁了

內容頁裡有上一篇跟下一篇;

控制器:


<?  //新聞內    public function index04(){                $this->ff();                $idds = I('get.id');                         //上一篇        $shang = M('article')->where("a_id <$idds and a_keyword=489")->order('a_id desc')->limit('1')->find();//查資料            if($shang){//              判斷如果執行成功往前面扔        $this->assign('shang',$shang);       }              else{//         否則讓他的標題等於暫無吧            $shang['a_title'] = "暫無";                        $this->assign('shang',$shang);        }        //      下一篇//同上             $xia = M('article')->where("a_id >$idds and a_keyword=489")->order('a_id asc')->limit('1')->find();                  if($xia){                     $this->assign('xia',$xia);       }              else{                       $xia['a_title'] = "暫無";                       $this->assign('xia',$xia);        }                           $this->display('jiu:public/7-6newsview');     }

前端:


  <span class="prev">上一篇:<A href="{$shang.a_writer}?id={$shang.a_id}">{$shang.a_title}</A></span>           <span class="next">下一篇:<A href="{$xia.a_writer}?id={$xia.a_id}">{$xia.a_title}</A></span>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.