From d8eb35c355e938eb98e5e2a1452b32a8e4d5b097 Mon Sep 17 00:00:00 2001 From: manson Date: Tue, 29 Jul 2014 10:09:49 +0800 Subject: [PATCH] Fix sub-menu list --- app/controllers/site_menu_widgets_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/site_menu_widgets_controller.rb b/app/controllers/site_menu_widgets_controller.rb index e865888..a1aeb0a 100644 --- a/app/controllers/site_menu_widgets_controller.rb +++ b/app/controllers/site_menu_widgets_controller.rb @@ -6,8 +6,7 @@ class SiteMenuWidgetsController < ApplicationController if page.parent_page == Page.root pages = page.sorted_published_child_pages else - pages = page.sorted_published_child_pages - pages = page.parent_page.sorted_published_child_pages if pages.count == 0 + pages = page.parent_page.sorted_published_child_pages end def create_json(pages) items = [] @@ -17,12 +16,12 @@ class SiteMenuWidgetsController < ApplicationController if page.page_type == "page" or page.page_type == "link" item["page_name"] = page.name item["url"] = (page.page_type == "link") ? "/#{locale.to_s}" + page.external_url : "/#{locale.to_s}" + page.url - item["children"] = [] + item["children"] = create_json(page.sorted_published_child_pages) item["target"] = "_self" else item["page_name"] = page.name item["url"] = "/#{locale.to_s}" + page.url - item["children"] = [] + item["children"] = create_json(page.sorted_published_child_pages) item["target"] = "_blank" end else