Fix bugs in sub_menu
This commit is contained in:
parent
9ead6cafda
commit
909ca19456
|
@ -29,7 +29,7 @@ class Page < Item
|
||||||
def create_parts
|
def create_parts
|
||||||
page_design = self.design
|
page_design = self.design
|
||||||
parent = self.parent
|
parent = self.parent
|
||||||
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)}
|
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
|
||||||
page_design.layout.layout_parts.each do |layout_part|
|
page_design.layout.layout_parts.each do |layout_part|
|
||||||
current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
|
current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
|
||||||
current_part = self.page_parts.build(:name => layout_part.name) unless current_part
|
current_part = self.page_parts.build(:name => layout_part.name) unless current_part
|
||||||
|
|
|
@ -111,19 +111,21 @@ module ParserCommon
|
||||||
# sub_menus
|
# sub_menus
|
||||||
def parse_sub_menus(body = nil, page = nil, id = nil, edit=nil)
|
def parse_sub_menus(body = nil, page = nil, id = nil, edit=nil)
|
||||||
body.css('sub_menu').each do |sub_menu|
|
body.css('sub_menu').each do |sub_menu|
|
||||||
menu_page = Page.find(sub_menu['id'])
|
menu_page = Page.find(sub_menu['id']) rescue nil
|
||||||
res = ''
|
res = ''
|
||||||
|
if menu_page && menu_page.ordered_and_visible_children.size > 0
|
||||||
res << "<div class='category_list'>"
|
res << "<div class='category_list'>"
|
||||||
res << "<h3 class='h3'>#{menu_page.i18n_variable[I18n.locale]}</h3>"
|
res << "<h3 class='h3'>#{menu_page.i18n_variable[I18n.locale]}</h3>"
|
||||||
res << "<ul class='list'>"
|
res << "<ul class='list'>"
|
||||||
menu_page.ordered_and_visible_children.each do |child|
|
menu_page.ordered_and_visible_children.each do |child|
|
||||||
res << "<li class='#{page.id.eql?(child.id) ? 'active' : nil}'>"
|
res << "<li class='#{page.id.eql?(child.id) ? 'active' : nil}'>"
|
||||||
res << "<a href='#{edit ? admin_page_path(child.id) : child.full_name}'>#{child.i18n_variable[I18n.locale]}</a>"
|
res << "<a href='/#{edit ? admin_page_path(child.id) : child.full_name}'>#{child.i18n_variable[I18n.locale]}</a>"
|
||||||
res << "</li>"
|
res << "</li>"
|
||||||
end
|
end
|
||||||
res << "</ul>"
|
res << "</ul>"
|
||||||
res << "</h3>"
|
res << "</h3>"
|
||||||
res << "</div>"
|
res << "</div>"
|
||||||
|
end
|
||||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||||
sub_menu.swap(fragment)
|
sub_menu.swap(fragment)
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue