想修改PHPCMS分页的URL 有好人吗
答案:2 悬赏:40 手机版
解决时间 2021-01-29 09:37
- 提问者网友:趣果有间
- 2021-01-28 09:16
想修改PHPCMS分页的URL 有好人吗
最佳答案
- 五星知识达人网友:罪歌
- 2021-01-28 10:30
PHP codefunction pages($num, $curr_page, $perpage = 20, $urlrule = '', $array = array(), $catid = 0)
{
global $PHPCMS;
if($PHPCMS['pagemode'] && $num > $perpage)
{
$url = load('url.class.php');
$multipage = '';
if($num > $perpage)
{
$page = 11;
$offset = 4;
$pages = ceil($num / $perpage);
$from = $curr_page - $offset;
$to = $curr_page + $offset;
$more = 0;
if($page >= $pages)
{
$from = 2;
$to = $pages-1;
}
else
{
if($from <= 1)
{
$to = $page-1;
$from = 2;
}
elseif($to >= $pages)
{
$from = $pages-($page-2);
$to = $pages-1;
}
$more = 1;
}
if($urlrule == '') $urlrule = url_par('page={$page}');
$multipage .= '总数:'.$num.' ';
if($curr_page>0)
{
$multipage .= $catid ? 'category($catid, $curr_page-1, 1, 1).'" target="_blank">上一页' : '上一页';
if($curr_page==1)
{
$multipage .= '1 ';
}
elseif($curr_page>6 && $more)
{
$multipage .= $catid ? 'category($catid, 1, 1, 1).'" target="_blank">1..' : '1..';
}
else
{
$multipage .= $catid ? 'category($catid, 1, 1, 1).'" target="_blank">1' : '1 ';
}
}
for($i = $from; $i <= $to; $i++)
{
if($i != $curr_page)
{
$multipage .= $catid ? 'category($catid, $i, 1, 1).'" target="_blank">'.$i.' ' : ''.$i.' ';
}
else
{
$multipage .= ' '.$i.' ';
}
}
if($curr_page<$pages)
{
if($curr_page<$pages-5 && $more)
{
$multipage .= $catid ? '..category($catid, $pages, 1, 1).'" target="_blank">'.$pages.' category($catid, $curr_page+1, 1).'" target="_blank">下一页' : '..'.$pages.' 下一页';
}
else
{
$multipage .= $catid ? 'category($catid, $pages, 1, 1).'" target="_blank">'.$pages.' category($catid, $curr_page+1, 1, 1).'" target="_blank">下一页' : ''.$pages.' 下一页';
}
}
elseif($curr_page==$pages)
{
$multipage .= ' '.$pages.'下一页';
}
}
return $multipage;
}
else
{
$total = $num;
$page = $curr_page;
if($num < 1) return '';
if($urlrule == '') $urlrule = url_par('page={$page}');
$pages = ceil($total/$perpage);
$page = min($pages, $page);
$prepage = $page - 1;
$prepage = max($prepage, 1);
$nextpage = $page+1;
$nextpage = min($nextpage, $pages);
if($catid)
{
$url = load('url.class.php');
$firstpage = $url->category($catid, 1, 1, 1);
$prepage = $url->category($catid, $prepage, 1, 1);
$nextpage = $url->category($catid, $nextpage, 1, 1);
$lastpage = $url->category($catid, $pages, 1, 1);
$urlpre = $url->category($catid, '', 1, 1);
}
else
{
$firstpage = pageurl($urlrule, 1, $array);
$prepage = pageurl($urlrule, $prepage, $array);
$nextpage = pageurl($urlrule, $nextpage, $array);
$lastpage = pageurl($urlrule, $pages, $array);
$urlpre = pageurl($urlrule, '', $array);
}
$data = str_replace('"', '\"', $PHPCMS['pageshtml']);
eval("\$url = \"$data\";");
return $url;
}
}
弄了几天了.还是弄不懂
$multipage .= $catid ? 'category($catid, $curr_page-1, 1, 1).'" target="_blank">上一页' : '上一页';
这一句
$url->category($catid, $curr_page-1, 1, 1)
引用的是哪里..
引用的是这个:$url = load('url.class.php'); 文件中的类。
{
global $PHPCMS;
if($PHPCMS['pagemode'] && $num > $perpage)
{
$url = load('url.class.php');
$multipage = '';
if($num > $perpage)
{
$page = 11;
$offset = 4;
$pages = ceil($num / $perpage);
$from = $curr_page - $offset;
$to = $curr_page + $offset;
$more = 0;
if($page >= $pages)
{
$from = 2;
$to = $pages-1;
}
else
{
if($from <= 1)
{
$to = $page-1;
$from = 2;
}
elseif($to >= $pages)
{
$from = $pages-($page-2);
$to = $pages-1;
}
$more = 1;
}
if($urlrule == '') $urlrule = url_par('page={$page}');
$multipage .= '总数:'.$num.' ';
if($curr_page>0)
{
$multipage .= $catid ? 'category($catid, $curr_page-1, 1, 1).'" target="_blank">上一页' : '上一页';
if($curr_page==1)
{
$multipage .= '1 ';
}
elseif($curr_page>6 && $more)
{
$multipage .= $catid ? 'category($catid, 1, 1, 1).'" target="_blank">1..' : '1..';
}
else
{
$multipage .= $catid ? 'category($catid, 1, 1, 1).'" target="_blank">1' : '1 ';
}
}
for($i = $from; $i <= $to; $i++)
{
if($i != $curr_page)
{
$multipage .= $catid ? 'category($catid, $i, 1, 1).'" target="_blank">'.$i.' ' : ''.$i.' ';
}
else
{
$multipage .= ' '.$i.' ';
}
}
if($curr_page<$pages)
{
if($curr_page<$pages-5 && $more)
{
$multipage .= $catid ? '..category($catid, $pages, 1, 1).'" target="_blank">'.$pages.' category($catid, $curr_page+1, 1).'" target="_blank">下一页' : '..'.$pages.' 下一页';
}
else
{
$multipage .= $catid ? 'category($catid, $pages, 1, 1).'" target="_blank">'.$pages.' category($catid, $curr_page+1, 1, 1).'" target="_blank">下一页' : ''.$pages.' 下一页';
}
}
elseif($curr_page==$pages)
{
$multipage .= ' '.$pages.'下一页';
}
}
return $multipage;
}
else
{
$total = $num;
$page = $curr_page;
if($num < 1) return '';
if($urlrule == '') $urlrule = url_par('page={$page}');
$pages = ceil($total/$perpage);
$page = min($pages, $page);
$prepage = $page - 1;
$prepage = max($prepage, 1);
$nextpage = $page+1;
$nextpage = min($nextpage, $pages);
if($catid)
{
$url = load('url.class.php');
$firstpage = $url->category($catid, 1, 1, 1);
$prepage = $url->category($catid, $prepage, 1, 1);
$nextpage = $url->category($catid, $nextpage, 1, 1);
$lastpage = $url->category($catid, $pages, 1, 1);
$urlpre = $url->category($catid, '', 1, 1);
}
else
{
$firstpage = pageurl($urlrule, 1, $array);
$prepage = pageurl($urlrule, $prepage, $array);
$nextpage = pageurl($urlrule, $nextpage, $array);
$lastpage = pageurl($urlrule, $pages, $array);
$urlpre = pageurl($urlrule, '', $array);
}
$data = str_replace('"', '\"', $PHPCMS['pageshtml']);
eval("\$url = \"$data\";");
return $url;
}
}
弄了几天了.还是弄不懂
$multipage .= $catid ? 'category($catid, $curr_page-1, 1, 1).'" target="_blank">上一页' : '上一页';
这一句
$url->category($catid, $curr_page-1, 1, 1)
引用的是哪里..
全部回答
- 1楼网友:孤独的牧羊人
- 2021-01-28 11:17
<!--分页--> <div id="pages"></div> <!--ps: 文章内上一页的地址.-->""+"&page="+"$page-1" <!--ps: 文章内下一页的地址.-->""+"&page="+"$page+1" <!--ps: 文章内当前页页的地址.-->""+"&page="+"$page" 加我qq, 应用好给你.
如果帮助到您,请记得采纳为满意答案哈,谢谢!祝您生活愉快! vae.la
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯