Add footer to site_info

This commit is contained in:
Christophe Vilayphiou 2012-05-07 11:25:33 +08:00
parent 1fb6c20b86
commit 0246341aef
2 changed files with 31 additions and 13 deletions

View File

@ -16,6 +16,7 @@ class Site
field :department
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :footer, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_many :site_metas, :autosave => true, :dependent => :destroy
before_save :set_key
@ -40,6 +41,10 @@ class Site
@title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
def footer
@footer ||= I18nVariable.first(:conditions => {:key => 'footer', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
METAS.each do |meta|
define_method meta do
fetch_meta = self.site_metas.where(key: meta).limit(1)
@ -58,7 +63,8 @@ class Site
protected
def set_key
title.key = 'title' if title
title.key = 'title' if title && (title.key.blank? rescue true)
footer.key = 'footer' if footer && (footer.key.blank? rescue true)
end
end

View File

@ -14,18 +14,30 @@
<div class="tab-content">
<% @site_valid_locales.each do |locale|%>
<%= content_tag :div, :class => "tab-pane #{active_when_current_locale_eq locale}", :id => "#{locale}" do %>
<div>
<%= t :title %>
<%= f.fields_for :title, @site.title do |f| %>
<%= f.text_field locale %>
<% end %>
</div>
<div>
<%= t :keywords %>
<%= f.fields_for :keywords, @site.keywords do |f| %>
<%= f.text_field locale %>
<% end %>
</div>
<div>
<%= t :description %>
<%= f.fields_for :description, @site.description do |f| %>
<%= f.text_field locale %>
<% end %>
</div>
<div>
<%= t :footer %>
<%= f.fields_for :footer, @site.footer do |f| %>
<%= f.text_area locale, :class => "tinymce_textarea" %>
<% end %>
</div>
<% end %>
<% end %>
</div>