Module: CamaleonCms::Admin::CategoryHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/camaleon_cms/admin/category_helper.rb
Instance Method Summary collapse
-
#cama_category_get_options_html(categories, level = 0, attrs = {}) ⇒ Object
build an array multiple with category items prefixed with - for each level categories: collection of categories level: internal iterator control attrs: (Hash) extra params max_level: (Integer) permit to stop iteration in certain level until_cats: (Array of cat ids) permit to stop iteration if current iteration is in this array exclude_cats: (Array of cat ids) exclude this categories from the list.
Instance Method Details
#cama_category_get_options_html(categories, level = 0, attrs = {}) ⇒ Object
build an array multiple with category items prefixed with - for each level categories: collection of categories level: internal iterator control attrs: (Hash) extra params
max_level: (Integer) permit to stop iteration in certain level
until_cats: (Array of cat ids) permit to stop iteration if current iteration is in this array
exclude_cats: (Array of cat ids) exclude this categories from the list
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/camaleon_cms/admin/category_helper.rb', line 11 def (categories, level = 0, attrs = {}) attrs = { max_level: 1000, until_cats: [], exclude_cats: [] }.merge(attrs) = [] categories.all.decorate.each do |category| next if attrs[:exclude_cats].include?(category.id) << [('—' * level) + category.the_title, category.id] children = attrs[:max_level] < level ? [] : category.children children = [] if attrs[:until_cats].include?(category.id) += (children, level + 1, attrs) unless children.empty? end end |