Class: ActiveadminSelleoCms::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveadminSelleoCms::Page
show all
- Includes:
- ContentTranslation
- Defined in:
- app/models/activeadmin_selleo_cms/page.rb
Defined Under Namespace
Classes: Translation
Class Method Summary
collapse
Instance Method Summary
collapse
included, #initialize_missing_translations, #translated_attribute
Class Method Details
.update_positions(page_ids) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 113
def self.update_positions(page_ids)
begin
ActiveRecord::Base.transaction do
page_ids.each_cons(2) do |pair|
Page.find(pair.last).move_to_right_of(Page.find(pair.first))
end
end
return true
rescue
return false
end
end
|
Instance Method Details
#breadcrumb ⇒ Object
97
98
99
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 97
def breadcrumb
self_and_ancestors.map(&:title).join(' » ').html_safe
end
|
#go_back_page ⇒ Object
126
127
128
129
130
131
132
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 126
def go_back_page
if parent and !parent.redirect_to_first_sub_page
parent
elsif parent
parent.go_back_page
end
end
|
#initialize_missing_sections ⇒ Object
67
68
69
70
71
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 67
def initialize_missing_sections
section_names.each do |section_name|
sections.build(name: section_name) unless sections.detect{|section| section.name == section_name}
end
end
|
#layout ⇒ Object
85
86
87
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 85
def layout
@layout ||= Layout.find(layout_name)
end
|
#roots ⇒ Object
93
94
95
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 93
def roots
Page.published.roots
end
|
#section_names ⇒ Object
81
82
83
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 81
def section_names
@section_names ||= layout.section_names
end
|
#set_nest(translation) ⇒ Object
63
64
65
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 63
def set_nest(translation)
translation.activeadmin_selleo_cms_page ||= self
end
|
#to_label ⇒ Object
77
78
79
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 77
def to_label
"#{'- ' * depth} #{title}"
end
|
#to_param ⇒ Object
89
90
91
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 89
def to_param
parent ? "#{parent.to_param}/#{slug}" : slug
end
|
#to_s ⇒ Object
73
74
75
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 73
def to_s
title
end
|
#url(options = {locale: true}) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
|
# File 'app/models/activeadmin_selleo_cms/page.rb', line 101
def url(options={locale: true})
_url = if is_link_url
link_url
elsif redirect_to_first_sub_page and children.published.any?
"/:locale/#{children.published.first.to_param}"
else
"/:locale/#{to_param}"
end
_url = _url.gsub(':locale', I18n.locale.to_s) if _url.match(/:locale/) and options[:locale]
_url
end
|