Sha256: 266c53cd55c9434cc064309d58c018f79c6c27fdcc2c4bc855d60b8ac4005800

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module Enjoy::Catalog
  module Controllers
    module Items
      extend ActiveSupport::Concern

      included do
        if Enjoy::Catalog.config.breadcrumbs_on_rails_support and insert_breadcrumbs
          add_breadcrumb I18n.t('enjoy.breadcrumbs.items'), :enjoy_items_path
        end
      end

      def index
        @item = item_class.enabled.sorted

        unless Enjoy::Catalog.config.items_per_page.nil?
          @item = @item.page(params[:page])
        end
      end

      def show
        @item = item_class.enabled.find(params[:id])

        if @item and @item.text_slug != params[:id]
          redirect_to @item, status_code: 301
          return true
        end

        if Enjoy::Catalog.config.breadcrumbs_on_rails_support and insert_breadcrumbs
          add_breadcrumb @item.name, url_for(@item)
        end
      end

      private
      def category_class
        Enjoy::Catalog::Category
      end
      def item_class
        Enjoy::Catalog::Item
      end
      def page_title
        if @item
          @item.page_title
        else
          super
        end
      end

      def insert_breadcrumbs
        true
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
enjoy_cms_catalog-0.4.0.1 lib/enjoy/catalog/controllers/items.rb