Display de page contexts in the mobile version as set in structure

This commit is contained in:
chris 2013-10-08 18:10:55 +08:00
parent b4f5fddc5c
commit 08a8d668ec
1 changed files with 9 additions and 1 deletions

View File

@ -43,7 +43,7 @@ class MobileController < ApplicationController
def page
@page_title = t('mobile.page')
@page_contexts = PageContext.where(:archived => false).page(params[:page_main]).per(15)
@page_contexts = get_sorted_page_from_structure
end
def page_content
@ -57,4 +57,12 @@ class MobileController < ApplicationController
@no_footer = true if request.path =~ /app/
end
def get_sorted_page_from_structure
page_contexts = Item.structure_ordered_items.inject([]){ |pages, page|
pages << page.page_contexts.where(archived: false).limit(1)[0] if page.is_a?(Page) && !page.page_contexts.blank?
pages
}
Kaminari.paginate_array(page_contexts).page(params[:page]).per(15)
end
end