Fix announcement pagination in front-end

This commit is contained in:
Christophe Vilayphiou 2012-03-01 10:58:31 +08:00
parent 0b1f83c042
commit 4dd9b7ffa4
6 changed files with 12 additions and 9 deletions

View File

@ -30,7 +30,11 @@ class PagesController < ApplicationController
end end
def index_from_link def index_from_link
redirect_to "/#{@item.full_name}" if params[:page]
redirect_to "/#{@item.full_name}?page=#{params[:page]}"
else
redirect_to "/#{@item.full_name}"
end
end end
def show_from_link def show_from_link

View File

@ -100,7 +100,7 @@ module ParserBackEnd
ret = '' ret = ''
if (tag.attributes["main"] == "true" && !page.module_app.nil?) if (tag.attributes["main"] == "true" && !page.module_app.nil?)
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}?inner=true&page_id=#{page.id}" ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}?inner=true&page_id=#{page.id}"
ret << "&bulletin_category_id=#{page.category}" if page[:category] ret << "&category_id=#{page.category}" if page[:category]
ret << "'></div>" ret << "'></div>"
else else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }

View File

@ -127,7 +127,7 @@ module ParserFrontEnd
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}" ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
ret << "/#{id}" if id ret << "/#{id}" if id
ret << "?inner=true&page_id=#{page.id}" ret << "?inner=true&page_id=#{page.id}"
ret << "&bulletin_category_id=#{page.category}" if page[:category] ret << "&category_id=#{page.category}" if page[:category]
ret << "'></div>" ret << "'></div>"
else else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil

View File

@ -11,15 +11,15 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController
def index def index
date_now = Time.now date_now = Time.now
if params[:bulletin_category_id] if params[:category_id]
@bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
else else
@bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
end end
get_categorys get_categorys
@current_category = BulletinCategory.from_id(params[:bulletin_category_id]) rescue nil @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
end end
def show def show

View File

@ -28,6 +28,6 @@
<% end %> <% end %>
</table> </table>
<%= paginate @bulletins %> <%= paginate @bulletins, :params => {:inner => 'false'} %>

View File

@ -13,7 +13,6 @@ Rails.application.routes.draw do
resources :tags resources :tags
end end
namespace :front_end do namespace :front_end do
root :to => "bulletins#index"
resources :bulletins resources :bulletins
end end
namespace :widget do namespace :widget do