classmypageplugin(object):
def__init__(self,totalitem,currentpage,url_a=none,perpageitem=3,showapage=9):
''':param totalitem: 總的條目數
:param perpageitem: 每頁顯示的條目
:param showapage: 顯示的頁面鏈結,預設為9
:param currentpage: 顯示的頁面鏈結,預設為9
:param url_a: 組成頁碼的url
'''self.total_itme=totalitem
self.per_page_item=perpageitem
self.show_a_page=showapage
self.current_page=currentpage
self.a_page_list=
self.total_page=self.get_total_page
self.url_a=url_a
#列表的開始
@property
defstart(self):
return (self.current_page-1)*self.per_page_item
#列表的結束
@property
defend(self):
return self.current_page*self.per_page_item
#總頁數
@property
defget_total_page(self):
total_pages_num, b =divmod(self.total_itme, self.per_page_item)
total_pages_num = total_pages_num + 1 if b else total_pages_num #
總頁數return
total_pages_num
#頁碼a鏈結列表
@property
defgetlistpagea(self):
##############頁碼鏈結列表#####################首頁
page_first = "
首頁" % (self.url_a,1)
if self.current_page <= 5:
for a_item in range(1, 9 + 1):
if self.current_page ==a_item:
tem_a = "
%s" %(self.url_a,a_item, a_item)
else
: tem_a = "
%s" %(self.url_a,a_item, a_item)
elif self.current_page >= self.total_page - 4:
for a_item in range(self.total_page - 9 + 1, self.total_page + 1):
if self.current_page ==a_item:
tem_a = "
%s" %(self.url_a,a_item, a_item)
else
: tem_a = "
%s" %(self.url_a,a_item, a_item)
else
:
for a_item in range(self.current_page - 4, self.current_page + 4 + 1):
if self.current_page ==a_item:
tem_a = "
%s" %(self.url_a,a_item, a_item)
else
: tem_a = "
%s" %(self.url_a,a_item, a_item)
#末頁page_last = "
末頁" %(self.url_a,self.total_page)
return self.a_page_list
python實現分頁外掛程式
class pages def init self,current page,data count,per page count 10,pager num 7 pager num 這是頁碼 self.current page current page self.data count data cou...
分頁外掛程式Kaminari
rails 2.x 中最常用的分頁外掛程式是 will paginate 這個相信大家都耳熟能詳 不過到 rails 3 以後,我發現乙個更好選擇,那就是 kaminari 我選擇它,主要是看中其直觀靈活的介面定製功能,它不像 will paginate 那樣需要配置一大堆引數,而是採用 view ...
jquery table分頁外掛程式
使用方法 2 新建js,我的為page.js,放入以下 jquery.extend else else var maxright currentpage center 1 if maxright allpage else else left currentpage center right left...