Module: Themes::PluginClass::MainHelper

Defined in:
lib/generators/camaleon_cms/gem_theme_template/app/helpers/themes/my_plugin/main_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object


2
3
4
# File 'lib/generators/camaleon_cms/gem_theme_template/app/helpers/themes/my_plugin/main_helper.rb', line 2

def self.included(klass)
  # klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
end

Instance Method Details

#pluginKey_on_install_theme(theme) ⇒ Object

callback called after theme installed


13
14
15
16
17
18
19
20
21
# File 'lib/generators/camaleon_cms/gem_theme_template/app/helpers/themes/my_plugin/main_helper.rb', line 13

def pluginKey_on_install_theme(theme)
  unless theme.get_field_groups.where(slug: "fields").any?
    group = theme.add_field_group({name: "Main Settings", slug: "fields", description: ""})
    group.add_field({"name"=>"Background color", "slug"=>"bg_color"},{field_key: "colorpicker"})
    group.add_field({"name"=>"Links color", "slug"=>"links_color"},{field_key: "colorpicker"})
    group.add_field({"name"=>"Background image", "slug"=>"bg"},{field_key: "image"})
  end
  theme.set_meta("installed_at", Time.current.to_s) # save a custom value
end

#pluginKey_on_uninstall_theme(theme) ⇒ Object

callback executed after theme uninstalled


24
25
# File 'lib/generators/camaleon_cms/gem_theme_template/app/helpers/themes/my_plugin/main_helper.rb', line 24

def pluginKey_on_uninstall_theme(theme)
end

#pluginKey_settings(theme) ⇒ Object


6
7
8
9
10
# File 'lib/generators/camaleon_cms/gem_theme_template/app/helpers/themes/my_plugin/main_helper.rb', line 6

def pluginKey_settings(theme)
  # here your code on save settings for current site, by default params[:theme_fields] is auto saved into theme
  # Also, you can save your extra values added in admin/settings.html.erb
  # sample: theme.set_meta("my_key", params[:my_value])
end