Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BenMorganIO/df8b501ce7f045e6f631 to your computer and use it in GitHub Desktop.
Save BenMorganIO/df8b501ce7f045e6f631 to your computer and use it in GitHub Desktop.
Including Spree helpers into AlchemyCMS
Alchemy::Admin::BaseController.class_eval do
include Spree::Core::ControllerHelpers
include Spree::Core::ControllerHelpers::Store
helper Spree::Core::Engine.helpers
# it appears spree is overriding alchemy's layout when the helper methods are included
# in here, we basically "recall" alchemy's original code.
layout :set_layout
private
def set_layout
request.xhr? ? false : 'alchemy/admin'
end
end
Alchemy::Admin::PagesController.class_eval do
# Used by page preview iframe in Page#edit view.
# decorating to reset the layout of the application
def show
@preview_mode = true
Alchemy::Page.current_preview = @page
# Setting the locale to pages language, so the page content has it's correct translations.
::I18n.locale = @page.language_code
render layout: 'spree/layouts/spree_application'
end
end
Alchemy::BaseController.class_eval do
include Spree::Core::ControllerHelpers
include Spree::Core::ControllerHelpers::Store
helper Spree::Core::Engine.helpers
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment