cifans 发表于 2010-10-13 13:14:10

回复 10# sonic


    谢谢啊!
那现在针对news这个控制器,实现这个功能该怎么写呢?

sonic 发表于 2010-10-13 14:30:06

你就是要一个分页列表和一个文章细节两个方法吗?

cifans 发表于 2010-10-13 14:36:39

回复 12# sonic


    对的

sonic 发表于 2010-10-13 14:43:35

function index()
{
   if($this->is_page($this->uri->segment(3)))
   {
         //list here
         $this->list_news($this->uri->segment(3));
   }
   else
{
      //show detail here
      $this->show_detail($this->uri->segment(3));
}
}

function is_page($str)
{
    //check the string is a page or a news;
}

function list_news($page_exp)
{
   //deal with listing data
}

function show_detail($this->uri->segment(3))
{
    // collect the news info from db then put them to view file
}

//its' determin your database create.
//Needimake the db create & programe the sample script for you?

cifans 发表于 2010-10-15 10:07:18

回复 14# sonic


    thx!

cifans 发表于 2010-10-15 10:12:29

回复 14# sonic


    is_page 这个函数可以写一下么 ,麻烦你了!

sonic 发表于 2010-10-15 14:58:10

is_page()
假定我的文章的主键是纯数字的
那么这个主键值必然是1,2,3,4,5,6,7,8
不会含有字符串
但是我假定页面的URL参数都是按照这个标准
page_n
n可以是数字
那么就有两种东西了。
一种叫做字符串
一种叫做数字型字符串
这个很好分辨的用PHP内置的函数其实就可以了
function is_page()
{
if(is_numeric($this->uri->segment(3)))
return false;
return true;
}

cifans 发表于 2010-10-15 20:05:46

回复 17# sonic


    thx!
页: 1 [2]
查看完整版本: 分页和内容页在同一目录下如何实现? ci.org.cn/news/P5