# Modul gets PublishedPages and Categories used in application layout
module PageContent
  extend ActiveSupport::Concern
  include ApplicationHelper
  include CartHelper

  included do
    before_action :prepare_menu_content
    add_breadcrumb 'Home', :root_path
  end

  def prepare_menu_content
    @categories_for_menu = Category.where('parent_id = 1 AND active = 1')
                                   .order('name')
    @pages = PublishedPage.where('type_of != 3').order('priority ASC')
    @cart = Cart.where(uuid: cookie_cart_number).first
  end
end
