Module: Locomotive::PagesHelper
- Defined in:
- app/helpers/locomotive/pages_helper.rb
Instance Method Summary collapse
- #add_children_to_options(page, children, list) ⇒ Object
- #display_page_layouts? ⇒ Boolean
- #options_for_page_layouts ⇒ Object
- #options_for_page_redirect_type ⇒ Object
- #parent_pages_options ⇒ Object
Instance Method Details
#add_children_to_options(page, children, list) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/locomotive/pages_helper.rb', line 14 def (page, children, list) return list if page.parent_ids.include?(@page.id) || page == @page offset = '- ' * (page.depth || 0) * 2 list << ["#{offset}#{page.title}", page.id] if children children.each { |(_page, _children)| (_page, _children, list) } end list end |
#display_page_layouts? ⇒ Boolean
28 29 30 31 |
# File 'app/helpers/locomotive/pages_helper.rb', line 28 def display_page_layouts? ((@page.persisted? && @page.allow_layout? && @page.use_layout?) || !@page.persisted?) && !current_site.pages.layouts.empty? end |
#options_for_page_layouts ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/helpers/locomotive/pages_helper.rb', line 33 def layouts = current_site.pages.layouts.map do |_layout| [_layout.title, _layout._id] end @page.index? ? layouts : [[t(:no_layout, scope: 'locomotive.pages.form'), 'parent']] + layouts end |
#options_for_page_redirect_type ⇒ Object
41 42 43 44 45 46 |
# File 'app/helpers/locomotive/pages_helper.rb', line 41 def [ [t('redirect_type.permanent', scope: 'locomotive.pages.form'), 301], [t('redirect_type.temporary', scope: 'locomotive.pages.form'), 302] ] end |
#parent_pages_options ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'app/helpers/locomotive/pages_helper.rb', line 4 def [].tap do |list| build_page_tree.each do |(page, children)| next if page.not_found? (page, children, list) end end end |