public
Description: Pagination for Radiant with will_paginate
Clone URL: git://github.com/ihoka/radiant-paginate-extension.git
Configurable children level and find page by url.
ihoka (author)
Tue Jul 15 10:45:39 -0700 2008
commit  7766d2f42e4882c323b933f04802d32b29f41ff8
tree    0545f91979c737df8874d7015a8fb74dc1245c87
parent  8db9607987e365899b99e7ad633dbeedeff7e7e6
...
32
33
34
 
35
36
37
 
38
39
40
...
80
81
82
 
 
 
 
 
 
 
 
 
 
 
 
 
83
84
85
...
32
33
34
35
36
37
 
38
39
40
41
...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
0
@@ -32,9 +32,10 @@ module PaginateTags
0
   tag 'paginate' do |tag|
0
     tag.locals.previous_headers = {}
0
     
0
+ parents = paginate_find_parent_pages(tag)
0
     options = paginate_find_options(tag)
0
     
0
- paginated_children = tag.locals.page.children.paginate(options)
0
+ paginated_children = Page.paginate(options.merge(:conditions => ['pages.parent_id in (?)', parents]))
0
     tag.locals.paginated_children = paginated_children
0
     
0
     tag.expand
0
@@ -80,6 +81,19 @@ module PaginateTags
0
   end
0
   
0
   private
0
+ def paginate_find_parent_pages(tag)
0
+ attr = tag.attr.symbolize_keys
0
+
0
+ level = (attr[:level] || '1').to_i
0
+ page = attr[:url] && Page.find_by_url(attr[:url]) || tag.locals.page
0
+
0
+ if level == 2
0
+ page.children.map(&:id)
0
+ else
0
+ [page.id]
0
+ end
0
+ end
0
+
0
     def paginate_find_options(tag)
0
       attr = tag.attr.symbolize_keys
0
       

Comments

    No one has commented yet.