Module: C::StorefrontHelper

Defined in:
app/helpers/c/storefront_helper.rb

Instance Method Summary collapse

Instance Method Details

#category_root_menuObject



18
19
20
21
22
# File 'app/helpers/c/storefront_helper.rb', line 18

def category_root_menu
   :ul do
    render partial: 'c/front/application/category_item', collection: C::Category.find_all_by_generation(0)
  end
end


4
5
6
7
8
9
10
# File 'app/helpers/c/storefront_helper.rb', line 4

def menu(menu_item_name, depth=1)
  return unless (menu_item = C::MenuItem.find_by(machine_name: menu_item_name))
  return unless menu_item.children.any?
   :ul do
    render partial: 'c/front/application/menu_item', collection: menu_item.children.includes(:page), cached: true, locals: { depth: depth }
  end
end


12
13
14
15
16
# File 'app/helpers/c/storefront_helper.rb', line 12

def menu_items_for(menu_item_name, depth=1)
  return unless (menu_item = C::MenuItem.find_by(machine_name: menu_item_name))
  return unless menu_item.children.any?
  render partial: 'c/front/application/menu_item', collection: menu_item.children.includes(:page), cached: true, locals: { depth: depth }
end

#meta_descriptionObject



40
41
42
43
# File 'app/helpers/c/storefront_helper.rb', line 40

def meta_description
  return unless @page_info&.meta_description&.present?
  tag :meta, name: :description, content: @page_info.meta_description
end

#meta_tagsObject



24
25
26
# File 'app/helpers/c/storefront_helper.rb', line 24

def meta_tags
  safe_join([page_title, meta_description]) if @page_info
end

#page_titleObject



28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/c/storefront_helper.rb', line 28

def page_title
  if @page_info.title.blank?
    if @page_info.fallback_title.blank?
      (:title, C.store_name)
    else
      (:title, @page_info.fallback_title)
    end
  else
    (:title, @page_info.title)
  end
end

#sales_highlights(page) ⇒ Object



54
55
56
57
58
59
60
61
# File 'app/helpers/c/storefront_helper.rb', line 54

def sales_highlights(page)
  case page
  when :home
    render partial: 'c/front/application/sales_highlight', collection: C::SalesHighlight.first(4), cached: true
  when :store
    render partial: 'c/front/application/sales_highlight', collection: C::SalesHighlight.first(3), cached: true
  end
end

#slideshow(slideshow_name, klass = nil) ⇒ Object



45
46
47
48
49
50
51
52
# File 'app/helpers/c/storefront_helper.rb', line 45

def slideshow(slideshow_name, klass=nil)
  return 'No slideshow found' unless (slide_show = C::Slideshow.find_by(machine_name: slideshow_name))
   :div, class: :slideshow do
     :ul do
      render partial: 'c/front/application/slide', collection: slide_show.slides.ordered, cached: true, locals: { klass: klass }
    end
  end
end