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 if page.parent_page == Page.root
pages = page.sorted_published_child_pages pages = page.sorted_published_child_pages
else else
pages = page.sorted_published_child_pages pages = page.parent_page.sorted_published_child_pages
pages = page.parent_page.sorted_published_child_pages if pages.count == 0
end end
def create_json(pages) def create_json(pages)
items = [] items = []
@ -17,12 +16,12 @@ class SiteMenuWidgetsController < ApplicationController
if page.page_type == "page" or page.page_type == "link" if page.page_type == "page" or page.page_type == "link"
item["page_name"] = page.name item["page_name"] = page.name
item["url"] = (page.page_type == "link") ? "/#{locale.to_s}" + page.external_url : "/#{locale.to_s}" + page.url 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" item["target"] = "_self"
else else
item["page_name"] = page.name item["page_name"] = page.name
item["url"] = "/#{locale.to_s}" + page.url item["url"] = "/#{locale.to_s}" + page.url
item["children"] = [] item["children"] = create_json(page.sorted_published_child_pages)
item["target"] = "_blank" item["target"] = "_blank"
end end
else else