forked from saurabh/orbit4-5
Fix route
This commit is contained in:
parent
05f0900621
commit
ddba41ce06
|
@ -17,21 +17,35 @@ class PagesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
page = Page.find_by_param(params[:page_id])
|
||||
module_app = page.module.downcase.pluralize
|
||||
params[:target_controller] = "#{module_app}"
|
||||
@manifest = @key
|
||||
@dataApi = nil
|
||||
if params[:slug]
|
||||
params[:target_action] = "show"
|
||||
params[:uid] = params[:slug].split("-").last
|
||||
else
|
||||
params[:target_action] = "index"
|
||||
params[:url] = page.url
|
||||
end
|
||||
OrbitHelper.set_params params
|
||||
OrbitHelper.set_site_locale locale
|
||||
render render_final_page("#{module_app}/#{params[:target_action]}",page)
|
||||
path = request.original_fullpath.split('/')
|
||||
if path.size == 2
|
||||
redirect_to '/'
|
||||
else
|
||||
if path.last.include? '-'
|
||||
params[:page_id] = path[-2]
|
||||
params[:slug] = path[-1]
|
||||
params[:uid] = path[-1].split("-").last
|
||||
params[:target_action] = "show"
|
||||
else
|
||||
params[:page_id] = path[-1]
|
||||
params[:slug] = nil
|
||||
params[:uid] = nil
|
||||
params[:target_action] = "index"
|
||||
end
|
||||
|
||||
page = Page.find_by_param(params[:page_id])
|
||||
module_app = page.module.downcase.pluralize
|
||||
params[:target_controller] = "#{module_app}"
|
||||
params[:url] = page.url
|
||||
|
||||
@manifest = @key
|
||||
@dataApi = nil
|
||||
|
||||
OrbitHelper.set_params params
|
||||
OrbitHelper.set_site_locale locale
|
||||
|
||||
render render_final_page("#{module_app}/#{params[:target_action]}",page)
|
||||
end
|
||||
end
|
||||
|
||||
def preview
|
||||
|
|
|
@ -18,7 +18,7 @@ OrbitStore::Application.routes.draw do
|
|||
# You can have the root of your site routed with "root"
|
||||
root 'home#index'
|
||||
scope "(:locale)", locale: /en|zh_tw/ do
|
||||
get ':page_id((/:page_id)/:page_id/:slug)', to: 'pages#show'
|
||||
get ':page(/:page)(/:page)(/:page)', to: 'pages#show'
|
||||
resources :pages
|
||||
end
|
||||
# Example of regular route:
|
||||
|
|
Loading…
Reference in New Issue