From f9cf40c6357282162518818a9306a950f06482df Mon Sep 17 00:00:00 2001 From: manson Date: Sun, 20 Jul 2014 04:17:21 +0800 Subject: [PATCH] Fix sub_menu list and url for link page --- app/controllers/site_menu_widgets_controller.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/site_menu_widgets_controller.rb b/app/controllers/site_menu_widgets_controller.rb index 718a8f7..19e8265 100644 --- a/app/controllers/site_menu_widgets_controller.rb +++ b/app/controllers/site_menu_widgets_controller.rb @@ -3,21 +3,25 @@ class SiteMenuWidgetsController < ApplicationController def widget params = OrbitHelper.params page = Page.where(:page_id => params[:page_id]).first - pages = page.sorted_published_child_pages + if page.parent_page == Page.root + pages = page.sorted_published_child_pages + else + pages = page.parent_page.sorted_published_child_pages + end def create_json(pages) items = [] pages.each do |page| item = {} if page.child_page.size > 0 - if page.page_type == "page" + if page.page_type == "page" or page.page_type == "link" item["page_name"] = page.name - item["url"] = "/#{locale.to_s}" + page.url - item["children"] = create_json(page.sorted_published_child_pages) + item["url"] = (page.page_type == "link") ? "/#{locale.to_s}" + page.external_url : "/#{locale.to_s}" + page.url + item["children"] = [] item["target"] = "_self" else item["page_name"] = page.name item["url"] = "/#{locale.to_s}" + page.url - item["children"] = create_json(page.sorted_published_child_pages) + item["children"] = [] item["target"] = "_blank" end else