Class: CamaleonCms::NavMenuItem

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

Constant Summary

Constants inherited from TermTaxonomy

TermTaxonomy::TRANSLATION_TAG_HIDE_MAP, TermTaxonomy::TRANSLATION_TAG_HIDE_REGEX, TermTaxonomy::TRANSLATION_TAG_RESTORE_MAP, TermTaxonomy::TRANSLATION_TAG_RESTORE_REGEX

Instance Method Summary collapse

Methods inherited from TermTaxonomy

#children, #in_nav_menu_items, inherited

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

Methods inherited from CamaleonRecord

#cama_build_cache_key, #cama_fetch_cache, #cama_get_cache, #cama_remove_cache, #cama_set_cache

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



37
38
39
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 37

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

#before_validatingObject



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

def before_validating; end

#have_children?Boolean

check if this menu have children

Returns:

  • (Boolean)


30
31
32
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 30

def have_children?
  children.count != 0
end

return the main menu



23
24
25
26
27
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 23

def main_menu
  return parent if parent

  parent_item&.main_menu
end

#skip_slug_validation?Boolean

overwrite skip uniq slug validation

Returns:

  • (Boolean)


48
49
50
# File 'app/models/camaleon_cms/nav_menu_item.rb', line 48

def skip_slug_validation?
  true
end

#update_menu_item(value) ⇒ Object

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



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

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