Class: DcSimpleMenu

Inherits:
Object
  • Object
show all
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

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.choices4_menu(site)
  rez = []
  menus = (site.menu_name.blank? ? all : where(name: site.menu_name)).to_a
  menus.each do |menu|
    rez << [menu.name, nil]
    menu.dc_simple_menu_items.where(active: true).order_by(:order => 1).each do |menu_item|
      rez << ['-- ' + menu_item.caption, menu_item._id]
    end
  end
  rez
end