Fix links in the menu when in edit or normal render
This commit is contained in:
parent
22c9ca4c74
commit
4ce0bda00b
|
@ -215,12 +215,12 @@ module Parser
|
||||||
c.define_tag 'menu' do |tag|
|
c.define_tag 'menu' do |tag|
|
||||||
home = get_homepage
|
home = get_homepage
|
||||||
menu = page.design.layout.menu
|
menu = page.design.layout.menu
|
||||||
menu_level(home, 1, menu)
|
menu_level(home, 1, menu, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_level(page, current, menu)
|
def menu_level(page, current, menu, edit = false)
|
||||||
if current <= menu.levels
|
if current <= menu.levels
|
||||||
res = "<ul id="
|
res = "<ul id="
|
||||||
res << menu.values["id_#{current}"]
|
res << menu.values["id_#{current}"]
|
||||||
|
@ -230,24 +230,24 @@ module Parser
|
||||||
i = nil
|
i = nil
|
||||||
i = 1 if menu.values["li_incremental_#{current}"]
|
i = 1 if menu.values["li_incremental_#{current}"]
|
||||||
if current == 1 && menu.values['home'].eql?('true')
|
if current == 1 && menu.values['home'].eql?('true')
|
||||||
res << menu_li(page, current, menu, i)
|
res << menu_li(page, current, menu, i, edit)
|
||||||
i += 1 if i
|
i += 1 if i
|
||||||
end
|
end
|
||||||
page.children.each do |child|
|
page.children.each do |child|
|
||||||
res << menu_li(child, current, menu, i)
|
res << menu_li(child, current, menu, i, edit)
|
||||||
i += 1 if i
|
i += 1 if i
|
||||||
end
|
end
|
||||||
res << "</ul>"
|
res << "</ul>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_li(page, current, menu, i)
|
def menu_li(page, current, menu, i, edit)
|
||||||
res = "<li class="
|
res = "<li class="
|
||||||
res << menu.values["li_class_#{current}"]
|
res << menu.values["li_class_#{current}"]
|
||||||
res << "_#{i}" if i
|
res << "_#{i}" if i
|
||||||
res << ">"
|
res << ">"
|
||||||
res << "<a href='#{page.full_name}'>#{page.name}</a>"
|
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}'>#{page.name}</a>"
|
||||||
res << menu_level(page, current + 1, menu) if page.children.size > 0 && !page.is_home?
|
res << menu_level(page, current + 1, menu, edit) if page.children.size > 0 && !page.is_home?
|
||||||
res << "</li>"
|
res << "</li>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Reference in New Issue