Fix links in the menu when in edit or normal render

This commit is contained in:
chris2tof 2011-09-05 16:18:49 +08:00
parent 22c9ca4c74
commit 4ce0bda00b
1 changed files with 7 additions and 7 deletions

View File

@ -215,12 +215,12 @@ module Parser
c.define_tag 'menu' do |tag|
home = get_homepage
menu = page.design.layout.menu
menu_level(home, 1, menu)
menu_level(home, 1, menu, true)
end
end
end
def menu_level(page, current, menu)
def menu_level(page, current, menu, edit = false)
if current <= menu.levels
res = "<ul id="
res << menu.values["id_#{current}"]
@ -230,24 +230,24 @@ module Parser
i = nil
i = 1 if menu.values["li_incremental_#{current}"]
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
end
page.children.each do |child|
res << menu_li(child, current, menu, i)
res << menu_li(child, current, menu, i, edit)
i += 1 if i
end
res << "</ul>"
end
end
def menu_li(page, current, menu, i)
def menu_li(page, current, menu, i, edit)
res = "<li class="
res << menu.values["li_class_#{current}"]
res << "_#{i}" if i
res << ">"
res << "<a href='#{page.full_name}'>#{page.name}</a>"
res << menu_level(page, current + 1, menu) if page.children.size > 0 && !page.is_home?
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}'>#{page.name}</a>"
res << menu_level(page, current + 1, menu, edit) if page.children.size > 0 && !page.is_home?
res << "</li>"
end