Fix sub_menu list and url for link page
This commit is contained in:
parent
61ce9d6acf
commit
f9cf40c635
|
@ -3,21 +3,25 @@ class SiteMenuWidgetsController < ApplicationController
|
||||||
def widget
|
def widget
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
page = Page.where(:page_id => params[:page_id]).first
|
page = Page.where(:page_id => params[:page_id]).first
|
||||||
|
if page.parent_page == Page.root
|
||||||
pages = page.sorted_published_child_pages
|
pages = page.sorted_published_child_pages
|
||||||
|
else
|
||||||
|
pages = page.parent_page.sorted_published_child_pages
|
||||||
|
end
|
||||||
def create_json(pages)
|
def create_json(pages)
|
||||||
items = []
|
items = []
|
||||||
pages.each do |page|
|
pages.each do |page|
|
||||||
item = {}
|
item = {}
|
||||||
if page.child_page.size > 0
|
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["page_name"] = page.name
|
||||||
item["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"] = create_json(page.sorted_published_child_pages)
|
item["children"] = []
|
||||||
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"] = create_json(page.sorted_published_child_pages)
|
item["children"] = []
|
||||||
item["target"] = "_blank"
|
item["target"] = "_blank"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue