时间:2021-07-03 08:25:51 | 栏目:ASP代码 | 点击:次
国外的核心代码:
for counter = 1 to lastpage
if counter = page then
pagination = pagination & "<span class=""current"">"&counter&"</span>"
else
pagination = pagination & "<a href="""&targetpage&""&"&page="&counter&""">"&counter&"</a>"
end if
next
elseif lastpage >= 7 + (adjacents * 2) then 'enough pages to hide some
'close to beginning only hide later pages
if page < 1 + (adjacents * 3) then
for counter = 1 to (4 + (adjacents * 2))-1
if counter = page then
pagination = pagination & "<span class=""current"">"&counter&"</span>"
else
pagination = pagination & "<a href="""&targetpage&"&page="&counter&""">"&counter&"</a>"
end if
next
pagination = pagination & "..."
pagination = pagination & "<a href="""&targetpage&""&"&page="&lpm1&""">"&lpm1&"</a>"
pagination = pagination & "<a href="""&targetpage&""&"&page="&lastpage&""">"&lastpage&"</a>"
'in middle hide some front and some back
elseif lastpage - (adjacents * 2) > page AND page > (adjacents * 2) then
pagination = pagination & "<a href="""&targetpage&"&page=1"">1</a>"
pagination = pagination & "<a href="""&targetpage&"&page=2"">2</a>"
pagination = pagination & "..."
for counter = (page - adjacents) to (page + adjacents)
if counter = page then
pagination = pagination & "<span class=""current"">"&counter&"</span>"
else
pagination = pagination & "<a href="""&targetpage&"&page="&counter&""">"&counter&"</a>"
end if
next
pagination = pagination & "..."
pagination = pagination & "<a href="""&targetpage&"&page="&lpm1&""">"&lpm1&"</a>"
pagination = pagination & "<a href="""&targetpage&"page="&lastpage&""">"&lastpage&"</a>"
'close to end only hide early pages
else
pagination = pagination & "<a href="""&targetpage&"&page=1"">1</a>"
pagination = pagination & "<a href="""&targetpage&"&page=2"">2</a>"
pagination = pagination & "..."
for counter = (lastpage - (1 + (adjacents * 3))) To lastpage
if counter = page then
pagination = pagination & "<span class=""current"">"&counter&"</span>"
else
pagination = pagination & "<a href="""&targetpage&"&page="&counter&""">"&counter&"</a>"
end if
next
end if
end if
'nextPage button
if page < counter - 1 then
pagination = pagination & "<a href="""&targetpage&"&page="&nextPage&""">Next</a>"
else
pagination = pagination & "<span class=""disabled"">Next</span>"
end if
pagination = pagination & "</div>" & vbnewline
end if
getPaginationString = pagination
end function
function Ceil( dividend, divider)
if (dividend mod divider) = 0 Then
Ceil = dividend / divider
ELSE
Ceil = Int(dividend / divider) + 1
End if
End function
'test script code
page = 1
if request("page") <> "" then
page=cint(request("page"))
end if
ps = getPaginationString(page, 1500, 15, 2, "pagination.asp?foo=bar")
Response.Write("<br /><br /><br /><br /><br /><br /><br /><br />"&ps)
%>
看了有些头晕,还是看点简单的吧,asp与php思想差不多啊,参考了dedecms的修改方法
效果图:
核心代码:
完整代码:
if cint(pageno)<mpage and mpage>1 then
lb=lb&"<a href=/list/list_"&theid&"_"&pageno+1&".htm title=""下页"">下页</a>"
else
lb=lb&"<a href='#'>下页</a>"
end if
if cint(pageno)< mpage then
lb=lb&"<a href=/list/list_"&theid&"_"&mpage&".htm title=""末页"">末页</a>"
end if