Class: CamaleonCms::NavMenuItem

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

Instance Method Summary collapse

Methods inherited from TermTaxonomy

#children, #in_nav_menu_items

Methods included from CustomFieldsRead

#add_custom_field_group, #add_custom_field_to_default_group, #get_field_groups, #get_field_object, #get_field_value, #get_field_values, #get_field_values_hash, #get_fields_grouped, #get_fields_object, #get_user_field_groups, #save_field_value, #set_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_metas, #set_option, #set_options

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


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

def append_menu_item(value)
  children.create({name: value[:label], url: value[:link], kind: value[:type], target: value[:target]})
end

#before_validatingObject


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

def before_validating; end

#have_children?Boolean

check if this menu have children

Returns:

  • (Boolean)

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

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

return the main menu


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

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

overwrite skip uniq slug validation

Returns:

  • (Boolean)

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

def skip_slug_validation?; true end

#update_menu_item(value) ⇒ Object

update current menu value: same as append_menu_item (label, link, target)


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

def update_menu_item(value)
  self.update({name: value[:label], url: value[:link], target: value[:target]})
end