昨天晚上意外发现我上格筑家的分页http://www.3j99.cn那个大按钮不好用了。
打开列表分页导航—“大图标响应式列表分页v4”标签查看问题
我是用的txt打开的代码。具体如下:
<LabelContent><style>
.pagination-lg .page-link {
padding: 0.5rem 1.2rem;
}
.page-item.active .page-link {
background-color: rgba(110,216,138,.9);
border-color: rgba(110,216,138,1);
}
</style>
<div class="center-block text-center" id="pageDiv" totalPage="{totalpage/}" style="margin-top:2rem">
<nav aria-label="..." class="d-flex" style="justify-content: center;">
<ul class="pagination pagination-lg" style="align-item:center;">
<li class="page-item" ><a class="page-link" href="{firsturl/}">&laquo;</a></li>
{loop range=\'4\'}
<li class="page-item" ><a class="page-link" href="{pageurl/}" id="bots{pageid/}">{pageid/}</a></li>$$$
<li class="page-item active" ><a class="page-link" href="{currenturl/}">{currentpage/}</a></li>{/loop}
<li class="page-item" ><a class="page-link" href="{endurl/}">&raquo;</a></li>
</ul>
</nav>
<div style="margin:auto;display:block;">
<div class="input-group input-group-lg" style="max-width:15rem; justify-content:center; margin-bottom:2rem; margin-left:auto;margin-right:auto;">
<span class="input-group-addon" style="max-width:7rem;">共{totalpage/}页 到</span>
<input style=" text-align: center;display:inline-block;" type="text" value="1" class="pages form-control" id="pages_t" size="1" style="width: auto; text-align: center;">
<span class="input-group-btn">
<button type="button" class="btn btn-success" onclick="pages()" ><i class="zi zi_handup"></i></button>
</span>
</div>
</div>
</div>
<script>
function pages(){
var a=document.getElementById("pages_t").value;
document.getElementById("bots"+a).click();
}
function pages(){ //动态分页下跳转
var a=document.getElementById("pages_t").value;
var firsturl='{firsturl/}';
var n1=firsturl.replace(/\.\w+$/,'').replace('1','').replace('_','');
var n2=/\.[^\.]+$/.exec(firsturl);
if(a>{endpage/})
window.location.href='{endurl/}';
else
{
if(a==1)
window.location.href=n1+n2;
else
window.location.href=n1+"_"+a+n2;
}
}
</script></LabelContent>
找到JS部分
<script>
function pages(){
var a=document.getElementById("pages_t").value;
document.getElementById("bots"+a).click();
}
function pages(){ //动态分页下跳转
var a=document.getElementById("pages_t").value;
var firsturl='{firsturl/}';
var n1=firsturl.replace(/\.\w+$/,'').replace('1','').replace('_','');
var n2=/\.[^\.]+$/.exec(firsturl);
if(a>{endpage/})
window.location.href='{endurl/}';
else
{
if(a==1)
window.location.href=n1+n2;
else
window.location.href=n1+"_"+a+n2;
}
}
</script>
逐浪CMSV8之后,<>都换为了>和>所以大家要看的懂
这个代码应该是MVC版转过来的,看这逻辑应该是
MVC是.aspx结尾,但V8是没有尾缀。所以上面的这个代码就不适用了。
n2会出现null的情况。所以应该先判断有没有尾缀,在V8中有尾缀的就是静态的,没有尾缀的就是动态的。加个判断改代码
废话不多说。上修正好的JS代码
<script>
function pages(){
var a=document.getElementById("pages_t").value;
document.getElementById("bots"+a).click();
}
function pages(){ //动态分页下跳转
var a=document.getElementById("pages_t").value;
var firsturl='index.shtml';
var n1=firsturl.replace(/\.\w+$/,'').replace('1','').replace('_','');
var n2=/\.[^\.]+$/.exec(firsturl);
console.log(n2)
if(n2 != null){
if(a>20){
window.location.href='index_20.shtml';
}else if(a==1){
window.location.href=n1+n2;;
}else{
console.log(n1+"_"+a)
window.location.href=n1+"_"+a+n2;;
}
}else{
if(a>20){
window.location.href='index_20.shtml';
}else if(a==1){
window.location.href=n1;
}else{
console.log(n1+"_"+a)
window.location.href=n1+"_"+a;
}
}
}
</script>
将<>转换一下
<LabelContent><style>
.pagination-lg .page-link {
padding: 0.5rem 1.2rem;
}
.page-item.active .page-link {
background-color: rgba(110,216,138,.9);
border-color: rgba(110,216,138,1);
}
</style>
<div class="center-block text-center" id="pageDiv" totalPage="{totalpage/}" style="margin-top:2rem">
<nav aria-label="..." class="d-flex" style="justify-content: center;">
<ul class="pagination pagination-lg" style="align-item:center;">
<li class="page-item" ><a class="page-link" href="{firsturl/}">&laquo;</a></li>
{loop range=\'4\'}
<li class="page-item" ><a class="page-link" href="{pageurl/}" id="bots{pageid/}">{pageid/}</a></li>$$$
<li class="page-item active" ><a class="page-link" href="{currenturl/}">{currentpage/}</a></li>{/loop}
<li class="page-item" ><a class="page-link" href="{endurl/}">&raquo;</a></li>
</ul>
</nav>
<div style="margin:auto;display:block;">
<div class="input-group input-group-lg" style="max-width:15rem; justify-content:center; margin-bottom:2rem; margin-left:auto;margin-right:auto;">
<span class="input-group-addon" style="max-width:7rem;">共{totalpage/}页 到</span>
<input style=" text-align: center;display:inline-block;" type="text" value="1" class="pages form-control" id="pages_t" size="1" style="width: auto; text-align: center;">
<span class="input-group-btn">
<button type="button" class="btn btn-success" onclick="pages()" ><i class="zi zi_handup"></i></button>
</span>
</div>
</div>
</div>
<script>
function pages(){
var a=document.getElementById("pages_t").value;
document.getElementById("bots"+a).click();
}
function pages(){ //动态分页下跳转
var a=document.getElementById("pages_t").value;
var firsturl='{firsturl/}';
var n1=firsturl.replace(/\.\w+$/,'').replace('1','').replace('_','');
var n2=/\.[^\.]+$/.exec(firsturl);
if(a>{endpage/})
window.location.href='{endurl/}';
else
{
if(a==1)
window.location.href=n1+n2;
else
window.location.href=n1+"_"+a+n2;
}
}
</script></LabelContent>
将上面的代码复制到txt打开的标签中位置即可