diff --git a/app/controllers/spree/static_content_controller.rb b/app/controllers/spree/static_content_controller.rb index 012c1955..9aca45e0 100644 --- a/app/controllers/spree/static_content_controller.rb +++ b/app/controllers/spree/static_content_controller.rb @@ -5,7 +5,7 @@ class Spree::StaticContentController < Spree::StoreController layout :determine_layout def show - @page = Spree::Page.visible.find_by_slug!(request.path) + @page = Spree::Page.by_store(current_store).visible.find_by_slug!(request.path) end private diff --git a/app/models/spree/page.rb b/app/models/spree/page.rb index 94ed5ad1..d0663410 100644 --- a/app/models/spree/page.rb +++ b/app/models/spree/page.rb @@ -1,6 +1,8 @@ class Spree::Page < ActiveRecord::Base default_scope -> { order("position ASC") } + has_and_belongs_to_many :stores, :join_table => 'spree_pages_stores' + validates_presence_of :title validates_presence_of [:slug, :body], :if => :not_using_foreign_link? validates_presence_of :layout, :if => :render_layout_as_partial? @@ -13,6 +15,8 @@ class Spree::Page < ActiveRecord::Base scope :footer_links, -> { where(:show_in_footer => true).visible } scope :sidebar_links, -> { where(:show_in_sidebar => true).visible } + scope :by_store, lambda { |store| joins(:stores).where("spree_pages_stores.store_id = ?", store) } + before_save :update_positions_and_slug def initialize(*args) diff --git a/app/views/spree/admin/pages/_form.html.erb b/app/views/spree/admin/pages/_form.html.erb index 6cf47890..d4c74a07 100644 --- a/app/views/spree/admin/pages/_form.html.erb +++ b/app/views/spree/admin/pages/_form.html.erb @@ -62,7 +62,15 @@ <%= f.label :render_layout_as_partial %> <% end %> + <%= f.field_container :stores do %> + <%= f.label :stores, Spree.t(:stores)%>
+ <% Spree::Store.all.each do |store| %> + <%= check_box_tag "page[store_ids][]", store.id, @page.stores.include?(store) %> <%= store.name %> + <% end %> + <% end %> + +
<%= f.field_container :meta_title do %> @@ -87,4 +95,4 @@
-
\ No newline at end of file + diff --git a/app/views/spree/static_content/_static_content_footer.html.erb b/app/views/spree/static_content/_static_content_footer.html.erb index 6466a03c..62a5d76a 100644 --- a/app/views/spree/static_content/_static_content_footer.html.erb +++ b/app/views/spree/static_content/_static_content_footer.html.erb @@ -1,3 +1,3 @@ \ No newline at end of file + + diff --git a/app/views/spree/static_content/_static_content_header.html.erb b/app/views/spree/static_content/_static_content_header.html.erb index 417767c9..1129a8df 100644 --- a/app/views/spree/static_content/_static_content_header.html.erb +++ b/app/views/spree/static_content/_static_content_header.html.erb @@ -1 +1 @@ -<%= render :partial => "spree/static_content/static_content_list", :collection => Spree::Page.visible.header_links, :as => :page %> \ No newline at end of file +<%= render :partial => "spree/static_content/static_content_list", :collection => Spree::Page.by_store(current_store).visible.header_links, :as => :page %> diff --git a/app/views/spree/static_content/_static_content_sidebar.html.erb b/app/views/spree/static_content/_static_content_sidebar.html.erb index 7c58c7c3..d2cd30d2 100644 --- a/app/views/spree/static_content/_static_content_sidebar.html.erb +++ b/app/views/spree/static_content/_static_content_sidebar.html.erb @@ -1,4 +1,4 @@ -<% if Spree::Page.visible.sidebar_links.any? %> +<% if Spree::Page.by_store(current_store).visible.sidebar_links.any? %>