Sha256: 9de6e8cf7553c492395a007c70a0c9ae1f37f6007cebfe288024325180d55799

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

=begin
  Camaleon CMS is a content management system
  Copyright (C) 2015 by Owen Peredo Diaz
  Email: owenperedo@gmail.com
  This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the  GNU Affero General Public License (GPLv3) for more details.
=end
#encoding: utf-8
module CamaleonCms::Admin::CategoryHelper

  # build an array multiple with category items prefixed with - for each level
  # categories: collection of categories
  # level: internal iterator control
  def cama_category_get_options_html(categories, level = 0)
    options = []
    categories.all.decorate.each do |category|
      options << [("—"*level) + category.the_title, category.id] unless @category.id == category.id
      children = category.children
      options += cama_category_get_options_html(children, level + 1) if children.size > 0
    end
    options
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
camaleon_cms-2.1.2.1 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.2.1 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.2.0 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.1.2.0 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.1.1.4 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.1.1 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.1.0 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.0.4.1 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.0.4 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.0.3 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.0.2 app/helpers/camaleon_cms/admin/category_helper.rb
camaleon_cms-2.0.1 app/helpers/camaleon_cms/admin/category_helper.rb