Class: Panda::CMS::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Panda::CMS::PagesController
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- app/controllers/panda/cms/pages_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
#add_breadcrumb, #authenticate_admin_user!, #authenticate_user!, #breadcrumbs, #current_user, #set_current_request_details, #user_signed_in?
Methods included from ApplicationHelper
#active_link?, #block_link_to, #component, #level_indent, #menu_indent, #nav_class, #nav_highlight_colour_classes, #panda_cms_editor, #panda_cms_form_with, #selected_nav_highlight_colour_classes, #table_indent, #title_tag
Instance Method Details
#root ⇒ Object
12 13 14 15 |
# File 'app/controllers/panda/cms/pages_controller.rb', line 12 def root params[:path] = "" show end |
#show ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/panda/cms/pages_controller.rb', line 17 def show page = if @overrides&.dig(:page_path_match) Panda::CMS::Page.find_by(path: @overrides[:page_path_match]) else Panda::CMS::Page.find_by(path: "/#{params[:path]}") end Panda::CMS::Current.page = page || Panda::CMS::Page.find_by(path: "/404") Panda::CMS::Current.page.title = @overrides&.dig(:title) || page.title if @overrides layout = page&.template&.file_path if page.nil? || page.status == "archived" || layout.nil? # This works for now, but we may want to override in future (e.g. custom 404s) render file: "#{Rails.root}/public/404.html", layout: false, status: :not_found and return end template_vars = { page: page, title: Panda::CMS::Current.page&.title || Panda::CMS.config.title } render inline: "", assigns: template_vars, status: :ok, layout: layout end |