Skip to content

Commit

Permalink
Merge pull request #2307 from mamhoff/set-preview-mode-earlier
Browse files Browse the repository at this point in the history
Set preview mode earlier
  • Loading branch information
tvdeyen authored Apr 21, 2022
2 parents d1fec7c + eca0e02 commit 93c850f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/controllers/alchemy/admin/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class PagesController < ResourcesController
before_action :set_root_page,
only: [:index, :show, :order]

before_action :run_on_page_layout_callbacks,
if: :run_on_page_layout_callbacks?,
only: [:show]
before_action :set_preview_mode, only: [:show]

before_action :load_languages_and_layouts,
unless: -> { @page_root },
Expand All @@ -35,6 +33,10 @@ class PagesController < ResourcesController

before_action :set_page_version, only: [:show, :edit]

before_action :run_on_page_layout_callbacks,
if: :run_on_page_layout_callbacks?,
only: [:show]

def index
@query = @current_language.pages.contentpages.ransack(search_filter_params[:q])

Expand Down Expand Up @@ -64,7 +66,6 @@ def tree
# Used by page preview iframe in Page#edit view.
#
def show
@preview_mode = true
Page.current_preview = @page
# Setting the locale to pages language, so the page content has it's correct translations.
::I18n.locale = @page.language.locale
Expand Down Expand Up @@ -397,6 +398,10 @@ def load_languages_and_layouts
@languages_with_page_tree = Language.on_current_site.with_root_page
@page_layouts = PageLayout.layouts_for_select(@language.id)
end

def set_preview_mode
@preview_mode = true
end
end
end
end

0 comments on commit 93c850f

Please sign in to comment.