Class: CamaleonCms::NavMenuItem

Inherits:
TermTaxonomy
  • Object
show all
Defined in:
app/models/camaleon_cms/nav_menu_item.rb

Overview

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.

Instance Method Summary collapse

Methods inherited from TermTaxonomy

#children, #in_nav_menu_items, #set_options_from_form

Methods included from CustomFieldsRead

#add_custom_field_group, #add_custom_field_to_default_group, #get_field!, #get_field_groups, #get_field_object, #get_field_value, #get_field_values, #get_field_values_hash, #get_fields_object, #get_user_field_groups, #save_field_value, #set_field_values, #update_field_value

Methods included from Metas

#delete_meta, #delete_option, #fix_save_metas_options_no_changed, #get_meta, #get_option, #options, #save_metas_options, #save_metas_options_skip, #set_meta, #set_multiple_options, #set_option

Instance Method Details

#append_menu_item(value) ⇒ Object

add sub menu for a menu item same values of NavMenu#append_menu_item return item created


40
41
42
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 40

def append_menu_item(value)
  children.create({name: value[:label], data_options: {type: value[:type], object_id: value[:link]}})
end

#get_typeObject

return the type of this menu (post|category|post_tag|post_type|external)


28
29
30
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 28

def get_type
  self.get_option('type')
end

#have_children?Boolean

check if this menu have children


33
34
35
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 33

def have_children?
  self.children.count != 0
end

return the main menu


20
21
22
23
24
25
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 20

def main_menu
  main_menu = self.parent
  return main_menu if main_menu.present?
  parent_menu = self.parent_item
  parent_menu.main_menu if parent_menu.present?
end

#skip_slug_validation?Boolean

skip uniq slug validation


45
46
47
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 45

def skip_slug_validation?
  true
end