首页 > 其他分享 >帝国cms输入页码实现分页跳转方式

帝国cms输入页码实现分页跳转方式

时间:2023-01-06 14:13:41浏览次数:38  
标签:gotopage totalpage cms multipage 跳转 fun 页码 page

函数地址(e>class>t_function.php>sys_ShowListMorePage())

//列表模板之列表式分页
function sys_ShowListMorePage($num,$page,$dolink,$type,$totalpage,$line,$ok,$search="",$add){
    var_dump(2);
	global $fun_r,$public_r;
	if($num<=$line)
	{
		$pager['showpage']='';
		return $pager;
	}
	//文件名
	if(empty($add['dofile']))
	{
		$add['dofile']='index';
	}
	//静态页数
	$repagenum=$add['repagenum'];
	$page_line=$public_r['listpagelistnum'];
	$snum=2;
	//$totalpage=ceil($num/$line);//取得总页数 wong 2022/12/19
	$firststr='<a title="Total record">&nbsp;<b>'.$num.'条/'.$totalpage.'页</b> </a>&nbsp;&nbsp;';
	//上一页
	if($page<>1)
	{
		$toppage='<span><a href="'.$dolink.$add['dofile'].$type.'">'.$fun_r['startpage'].'</a></span>';
		$pagepr=$page-1;
		if($pagepr==1)
		{
			$prido=$add['dofile'].$type;
		}
		else
		{
			$prido=$add['dofile'].'_'.$pagepr.$type;
		}
		$prepage='<span class="shang"><a href="'.$dolink.$prido.'">'.$fun_r['pripage'].'</a></span>';
	}else{
		$toppage='<span class="first disabled shang"><a href="javascript:void(0);">'.$fun_r['startpage'].'</a></span>';
	}
	//下一页
	if($page!=$totalpage)
	{
		$pagenex=$page+1;
		$nextpagelink=$repagenum&&$repagenum<$pagenex?eReturnRewritePageLink2($add,$pagenex):$dolink.$add['dofile'].'_'.$pagenex.$type;
		$lastpagelink=$repagenum&&$repagenum<$totalpage?eReturnRewritePageLink2($add,$totalpage):$dolink.$add['dofile'].'_'.$totalpage.$type;
		$nextpage='<span class="xia"><a href="'.$nextpagelink.'">'.$fun_r['nextpage'].'</a></span>';
		$lastpage='<span><a href="'.$lastpagelink.'">'.$fun_r['lastpage'].'</a></span>';
	}else{
		$lastpage='<span class="first disabled xia"><a href="javascript:void(0);">'.$fun_r['lastpage'].'</a></span>';
	}
	$starti=$page-$snum<1?1:$page-$snum;
	$no=0;
	for($i=$starti;$i<=$totalpage&&$no<$page_line;$i++)
	{
		$no++;
		if($page==$i)
		{
			$is_1="<span><a class=\"current\">";
			$is_2="</a></span>";
		}
		elseif($i==1)
		{
			$is_1='<span><a href="'.$dolink.$add['dofile'].$type.'">';
			$is_2="</a></span>";
		}
		else
		{
			$thispagelink=$repagenum&&$repagenum<$i?eReturnRewritePageLink2($add,$i):$dolink.$add['dofile'].'_'.$i.$type;
			$is_1='<span><a href="'.$thispagelink.'">';
			$is_2="</a></span>";
		}
		$returnstr.=$is_1.$i.$is_2;
	}


    //取得下拉页码
    // 新增页面跳转下拉框 2022/12/5 wong
//    $multipage = "";
//    $multipage .= ' <select name="archive" onchange="document.location.href=this.options[this.selectedIndex].value;">';
//    $multipage .= "<option value='0'>跳转到</option>";
//    $multipage .= '<option value="'.$dolink.$add['dofile'].$type.'">'.'第1页'.'</option>';
//    for($i=1; $i<=($totalpage); $i++)
//    {
////        $multipage .= '<option value="'.eReturnRewritePageLink($add,$i).'">'.'第'.$i. '页'.'</option>';
//        $multipage .= '<option value="'.$dolink.$add['dofile'].'_'.$i.$type.'">'.'第'.$i. '页'.'</option>';
//    }
//    $multipage .= '</select>';

    //选择样式跳转分页 wong 2022/12/19
    $searchs = '<div class="g-input-page" id="fenye">
                            <input type="hidden" value="'.$dolink.$add['dofile'].'_{page}'.$type.'" id="urlrule">
                            <input type="hidden" value="'.$totalpage.'" id="totalpage">
                            跳到<input type="text" class="input" id="gotopage">页
                            <a href="javascript:;" class="btn page" onclick="gotoPage();">确定</a>
                        </div>';

    $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage.$searchs;
    $pager['showpage']=$returnstr;
    return $pager;
}

需要搭配前段代码实现

    //静态列表页输入页码跳转 wong 2022/12/19
    function gotoPage(){
        var gotopage = $('#gotopage').val();
        var urlRule = $('#urlrule').val();
        var totalpage = $('#totalpage').val();
        if(!isNaN(gotopage)){
            gotopage = Math.ceil(gotopage);
            totalpage = parseInt(totalpage);
            if(gotopage>1 && gotopage<=totalpage){
                var targetUrl = urlRule.replace('{page}',gotopage);
                window.location.href = targetUrl;
            }else if(gotopage==1){
                var targetUrl = urlRule.replace('_{page}','');
                window.location.href = targetUrl;
            }
            else{
                return false;
            }
        }else{
            return false;
        }
    }

标签:gotopage,totalpage,cms,multipage,跳转,fun,页码,page
From: https://www.cnblogs.com/face-every/p/17030241.html

相关文章