diff --git a/app/helpers/alchemy/elements_helper.rb b/app/helpers/alchemy/elements_helper.rb index 0d3e31e247..18f7c3c9b1 100644 --- a/app/helpers/alchemy/elements_helper.rb +++ b/app/helpers/alchemy/elements_helper.rb @@ -28,22 +28,6 @@ module ElementsHelper # <%= render_elements from_page: 'footer' %> # # - # === Fallback to elements from global page: - # - # You can use the fallback option as an override for elements that are stored on another page. - # So you can take elements from a global page and only if the user adds an element on current page the - # local one gets rendered. - # - # 1. You have to pass the the name of the element the fallback is for as for key. - # 2. You have to pass a page_layout name or {Alchemy::Page} from where the fallback elements is taken from as from key. - # 3. You can pass the name of element to fallback with as with key. This is optional (the element name from the for key is taken as default). - # - # <%= render_elements(fallback: { - # for: 'contact_teaser', - # from: 'sidebar', - # with: 'contact_teaser' - # }) %> - # # === Custom elements finder: # # Having a custom element finder class: @@ -76,8 +60,6 @@ module ElementsHelper # The amount of elements to be rendered (begins with first element found) # @option options [Number] :offset # The offset to begin loading elements from - # @option options [Hash] :fallback - # Define elements that are rendered from another page. # @option options [Boolean] :random (false) # Randomize the output of elements # @option options [Boolean] :reverse (false) diff --git a/lib/alchemy/elements_finder.rb b/lib/alchemy/elements_finder.rb index 66c06416a2..340ec15e0e 100644 --- a/lib/alchemy/elements_finder.rb +++ b/lib/alchemy/elements_finder.rb @@ -26,8 +26,6 @@ class ElementsFinder # Randomize the output of elements # @option options [Boolean] :reverse (false) # Reverse the load order - # @option options [Hash] :fallback - # Define elements that are loaded from another page if no element was found on given page. def initialize(options = {}) @options = options end @@ -83,6 +81,9 @@ def get_page(page_or_layout) when Alchemy::Page page_or_layout when String + Alchemy::Deprecation.warn "Passing a String as `from_page` option to " \ + "`render_elements` is deprecated and will be removed with Alchemy 6.0. " \ + "Please load the page beforehand and pass it as an object instead." Alchemy::Page.find_by( language: Alchemy::Language.current, page_layout: page_or_layout, @@ -92,6 +93,9 @@ def get_page(page_or_layout) end def fallback_required?(elements) + if options[:fallback] + Alchemy::Deprecation.warn "Passing `fallback` options to `render_elements` is deprecated an will be removed with Alchemy 6.0." + end options[:fallback] && elements .where(Alchemy::Element.table_name => {name: options[:fallback][:for]}) .none? diff --git a/spec/dummy/app/views/alchemy/page_layouts/_standard.html.erb b/spec/dummy/app/views/alchemy/page_layouts/_standard.html.erb index 41953126b6..3e90dca1ce 100644 --- a/spec/dummy/app/views/alchemy/page_layouts/_standard.html.erb +++ b/spec/dummy/app/views/alchemy/page_layouts/_standard.html.erb @@ -1,6 +1,6 @@