Class: BillyCms::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/billy_cms/page.rb

Instance Method Summary collapse

Instance Method Details

#additional_attribute(attribute_name) ⇒ Object



54
55
56
# File 'app/models/billy_cms/page.rb', line 54

def additional_attribute(attribute_name)
    self.additional_attributes_values[attribute_name.to_s] if self.additional_attributes_values.present?
end

#additional_attributesObject



48
49
50
51
52
# File 'app/models/billy_cms/page.rb', line 48

def additional_attributes
    type = PageType.find_by_name(self.page_type)
    return [] unless type.present?
    type.additional_attributes
end

#binariesObject



27
28
29
# File 'app/models/billy_cms/page.rb', line 27

def binaries
    pages.where(page_type: 'Binary').sort_by(&:order_key)
end

#binary?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/models/billy_cms/page.rb', line 44

def binary?
    self.page_type == 'Binary'
end

#boxesObject



23
24
25
# File 'app/models/billy_cms/page.rb', line 23

def boxes
    pages.where(page_type: 'box').sort_by(&:order_key)
end

#childrenObject



15
16
17
# File 'app/models/billy_cms/page.rb', line 15

def children
  pages.sort_by(&:order_key)
end

#cms_pathObject



11
12
13
# File 'app/models/billy_cms/page.rb', line 11

def cms_path
  get_cms_path_component_for_parent '', self
end

#is_in_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
# File 'app/models/billy_cms/page.rb', line 31

def is_in_path?(path)
  if path == '/'
    return slug == 'startseite' ? true : false
  end
  # byebug if id == 6
  reg = Regexp.new("^(#{cms_path})", 'i')
  path.match(reg) != nil
end


19
20
21
# File 'app/models/billy_cms/page.rb', line 19

def navigation
    self.children.reject { |page| page.hide_from_navigation? || page.page_type == 'Binary' || page.page_type == 'Box' }
end

#sibblingsObject



40
41
42
# File 'app/models/billy_cms/page.rb', line 40

def sibblings
  self.class.where(parent_page_id: parent_page_id).where.not(id: id).order(:order_key)
end