From 9310b4176047dc24fce5841237441882ffee2e2f Mon Sep 17 00:00:00 2001 From: Kyle Wilkinson Date: Mon, 13 Jun 2011 18:06:26 -0700 Subject: Modify the category view of the blog to show a paged view, rather than all blog posts. --- app/controllers/blog/categories_controller.rb | 4 ++++ app/views/blog/categories/show.html.erb | 13 ++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/controllers/blog/categories_controller.rb b/app/controllers/blog/categories_controller.rb index 4795e99..35a87c3 100644 --- a/app/controllers/blog/categories_controller.rb +++ b/app/controllers/blog/categories_controller.rb @@ -2,6 +2,10 @@ class Blog::CategoriesController < BlogController def show @category = BlogCategory.find(params[:id]) + @blog_posts = @category.posts.live.includes(:comments, :categories).paginate({ + :page => params[:page], + :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10) + }) end end diff --git a/app/views/blog/categories/show.html.erb b/app/views/blog/categories/show.html.erb index 324c0fe..caecbfd 100644 --- a/app/views/blog/categories/show.html.erb +++ b/app/views/blog/categories/show.html.erb @@ -1,14 +1,13 @@ <% content_for :body_content_title, @category.title %> <% content_for :body_content_left do %> - <% if @category.posts.any? %> -
- <%= render :partial => "/blog/shared/post", :collection => @category.posts %> -
+ <% if @blog_posts.any? %> +
+ <%= render :partial => "/blog/shared/post", :collection => @blog_posts %> + <%= will_paginate @blog_posts %> +
<% else %> -

- <%= t('.no_posts') %> -

+

<%= t('.no_blog_articles_yet') %>

<% end %> <% end %> -- cgit v1.2.3