谢谢啊!
那现在针对news这个控制器,实现这个功能该怎么写呢? 你就是要一个分页列表和一个文章细节两个方法吗? 回复 12# sonic
对的 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? 回复 14# sonic
thx! 回复 14# sonic
is_page 这个函数可以写一下么 ,麻烦你了! 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;
} 回复 17# sonic
thx!
页:
1
[2]