forked from refinery/refinerycms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_menu.html.erb
32 lines (32 loc) · 1.55 KB
/
_menu.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<%
dom_id ||= 'menu'
css ||= 'menu'
hide_children = RefinerySetting.find_or_set(:menu_hide_children, false) if hide_children.nil?
# Select top menu items unless 'roots' is supplied.
collection ||= @menu_pages
caching = ((defined?(cache_menu) && cache_menu) || RefinerySetting.find_or_set(:cache_menu, false)) && File.writable?(Rails.cache.cache_path)
cache_if(caching && !user_signed_in?, [Refinery.base_cache_key, "pages_menus", dom_id, Globalize.locale, request.path].join('_')) do
if (roots ||= collection.select{|p| p.parent_id.nil?}).present?
# In order to match items that aren't shown in menu and highlight their associations.
# This can be supplied if the logic is different in your case.
unless defined?(selected_item)
selected_item = collection.detect{|page| selected_page?(page)}
selected_item = @page if selected_item.nil?
end
-%>
<nav id='<%= dom_id %>' class='<%= %W(#{css} clearfix).join(' ') %>'>
<ul>
<%= render :partial => "/shared/menu_branch",
:collection => roots,
:locals => {
:hide_children => hide_children,
:sibling_count => (roots.length - 1),
:collection => collection,
:selected_item => selected_item,
:apply_css => true #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
}
-%>
</ul>
</nav>
<% end -%>
<% end -%>