#require_dependency "../../lib/optimacms/page_services/page_route_service.rb" #require_dependency "../../lib/optimacms/page_services/page_process_service.rb" module Optimacms class PagesController < Optimacms::ApplicationController def my_set_render_template(tpl_view, tpl_layout) @optimacms_tpl = tpl_view @optimacms_layout = tpl_layout end def my_set_meta(meta) @optimacms_meta_title = meta[:title] @optimacms_meta_keywords = meta[:keywords] @optimacms_meta_description = meta[:description] end def renderActionInOtherController(controller,action,params, tpl_view=nil, tpl_layout=nil) c = controller.new c.params = params #c.process_action(action, request) #c.dispatch(action, request) #c.send 'index_page' c.request = request #c.request.path_parameters = params.with_indifferent_access c.request.format = params[:format] || 'html' c.action_name = action c.response = ActionDispatch::Response.new c.send 'my_set_render' c.send 'my_set_render_template', tpl_view, tpl_layout c.send 'my_set_meta', @pagedata.meta #c.process_action(action) c.dispatch(action, request) #c.process_action(action, tpl_filename) #app = "NewsController".constantize.action(action) #app.process params # result #c c.response.body #app.response.body end def show @path = params[:url] @pagedata = PageServices::PageRouteService.find_page_by_url(@path, current_lang) if @pagedata.page.nil? not_found and return end # page mapped to controller @pagedata.url_vars.each do |k,v| params[k] = v end # process page if @pagedata.page.content_page? # content page #@content = @pagedata.get_content(@page) #@content = @page.content my_set_render_template @pagedata.template.path, @pagedata.layout.basename my_set_meta @pagedata.meta render @optimacms_tpl, :layout=>@optimacms_layout #render :text => @content, :layout => @page.layout.name return respond_to do |format| format.html { render :text => @content } end return else #@pagedata.generate_content # #c = renderActionInOtherController(@pagedata.controller_class, @pagedata.action, params, @pagedata.compiled_view_path, @pagedata.layout.basename) c = renderActionInOtherController(@pagedata.controller_class, @pagedata.action, params, @pagedata.template.path, @pagedata.layout.basename) render text: c return # THE END s = <<-eos From code
News on page
page = <%=@pg%>
hello
local page = <%=@pg%>
news count = <%=News.all.count%>