Fix sub-menu list

This commit is contained in:
manson 2014-07-29 10:09:49 +08:00
parent 5b7dadaa72
commit d8eb35c355
1 changed files with 3 additions and 4 deletions

View File

@ -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