Class: DcSimpleMenu
- Inherits:
-
Object
- Object
- DcSimpleMenu
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/dc_simple_menu.rb
Overview
Mongoid::Document model for dc_simple_menus collection.
Simple menus were first menu system developed for DRG CMS. They can be only two menu levels deep. Menus are described in dc_simple_menu_items embedded documents.
Class Method Summary collapse
-
.choices4_menu(site) ⇒ Object
Will return all top level menu items of specified menu.
Class Method Details
.choices4_menu(site) ⇒ Object
Will return all top level menu items of specified menu. Used in DcPage document for selecting top level selected menu, when document displayed in browser.
Called from DcApplicationHelper :dc_choices4_menu: method.
Parameters:
- Site
-
DcSite document. Site for which menu belongs to. If site is not specified
all current menus in collection will be returned.
Returns: Array. Of choices prepared for select input field.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/dc_simple_menu.rb', line 62 def self.(site) rez = [] = (site..blank? ? all : where(name: site.)).to_a .each do || rez << [.name, nil] ..where(active: true).order_by(:order => 1).each do || rez << ['-- ' + .caption, ._id] end end rez end |