From 08a8d668ec5c5a90360778d6226c4cbc5a103285 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 8 Oct 2013 18:10:55 +0800 Subject: [PATCH] Display de page contexts in the mobile version as set in structure --- app/controllers/mobile_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/mobile_controller.rb b/app/controllers/mobile_controller.rb index 369bfa22..3879c393 100644 --- a/app/controllers/mobile_controller.rb +++ b/app/controllers/mobile_controller.rb @@ -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