Sha256: abfe05203fdab2f2bcd9165a5dc967b2c1438293fc055eaa925856e428ecff3c

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

module Themes
  module New
    module CustomHelper
      def theme_custom_settings(theme)
        case params[:action_name]
        when 'settings'
          render 'themes/new/views/admin/settings'
        when 'save_settings'
          theme.set_field_values(params[:field_options])
          flash[:notice] = 'Settings saved!'
          redirect_to action: :settings, action_name: 'settings'
        end
      end

      def theme_custom_on_install_theme(theme)
        unless theme.get_field_groups.where(slug: 'theme_new_fields').any?
          group = theme.add_custom_field_group({ name: 'New theme settings', slug: 'theme_new_fields',
                                                 description: 'new theme' })
          group.add_manual_field({ 'name' => 'Background color', 'slug' => 'theme_custom_bg_color' },
                                 { field_key: 'colorpicker', required: true })
          group.add_manual_field({ 'name' => 'Links color', 'slug' => 'theme_custom_links_color' },
                                 { field_key: 'colorpicker', required: true })
          group.add_manual_field({ 'name' => 'Footer text', 'slug' => 'theme_custom_footer_text' },
                                 { field_key: 'editor', translate: true })
        end

        return if theme.site.nav_menus.where(slug: 'main_menu').any?

        theme.site.nav_menus.create(name: 'Main Menu', slug: 'main_menu')
      end

      def theme_custom_on_uninstall_theme(theme)
        theme.get_field_groups.destroy_all
        theme.destroy
      end
    end
  end
end

Version data entries

12 entries across 10 versions & 1 rubygems

Version Path
camaleon_cms-2.8.3 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.8.2 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.8.1 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.8.0 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.7.5 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.7.4 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.7.3 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.7.2 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.7.1 spec/dummy/app/apps/themes/new/custom_helper.rb
camaleon_cms-2.7.1 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.7.0 app/apps/themes/new/custom_helper.rb
camaleon_cms-2.7.0 spec/dummy/app/apps/themes/new/custom_helper.rb