Sha256: b723f49f70ad9948ee354da99b82f9ebc8081632461d642326a3eda581b5b728

Contents?: true

Size: 836 Bytes

Versions: 65

Compression:

Stored size: 836 Bytes

Contents

class CamaleonCms::Widget::Sidebar < CamaleonCms::TermTaxonomy
  default_scope { where(taxonomy: :sidebar) }
  has_many :metas, ->{ where(object_class: 'Widget::Sidebar')}, :class_name => "CamaleonCms::Meta", foreign_key: :objectid, dependent: :destroy
  has_many :assigned, foreign_key: :post_parent, dependent: :destroy
  belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id

  #scopes
  scope :default_sidebar, -> { where(:slug => 'default-sidebar') }
  scope :all_sidebar, -> { where("slug != 'default-sidebar'") }

  # assign the widget into this sidebar
  # widget: string(slug)/object
  # data: {title, content}
  def add_widget(widget, data = {})
    widget = self.site.widgets.where(slug: widget).first if widget.is_a?(String)
    data[:widget_id] = widget.id
    self.assigned.create(data)
  end

end

Version data entries

65 entries across 65 versions & 2 rubygems

Version Path
camaleon_cms-2.4.5.10 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.9 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.8 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.7 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.5 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.4 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.3 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.2 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5.1 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.5 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.4.7 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.4.6 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.4.5 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.4.4 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.4.3 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.4.2 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.4.1 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.4 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.3.13 app/models/camaleon_cms/widget/sidebar.rb
camaleon_cms-2.4.3.12 app/models/camaleon_cms/widget/sidebar.rb