Last active
August 29, 2015 14:03
-
-
Save BenMorganIO/df8b501ce7f045e6f631 to your computer and use it in GitHub Desktop.
Including Spree helpers into AlchemyCMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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