aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Sak <joe@joesak.com>2011-06-13 20:23:40 -0700
committerJoe Sak <joe@joesak.com>2011-06-13 20:23:40 -0700
commitdb821498767c05b1cc4cafa268593eac575597a0 (patch)
tree177fb3ced78f088bcf1ab54135f5497bc28abe64
parentb91b381e8eb6e5dc572ea4e53b138caba1a011fa (diff)
parenta31f28126a0099fbf3f4f694c52b109e73c92e08 (diff)
downloadrefinerycms-blog-db821498767c05b1cc4cafa268593eac575597a0.tar.gz
refinerycms-blog-db821498767c05b1cc4cafa268593eac575597a0.tar.bz2
refinerycms-blog-db821498767c05b1cc4cafa268593eac575597a0.zip
Merge pull request #74 from wikyd/master
Add Paging to Category Show View
-rw-r--r--app/controllers/blog/categories_controller.rb4
-rw-r--r--app/views/blog/categories/show.html.erb9
2 files changed, 9 insertions, 4 deletions
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..40444ec 100644
--- a/app/views/blog/categories/show.html.erb
+++ b/app/views/blog/categories/show.html.erb
@@ -1,10 +1,11 @@
<% content_for :body_content_title, @category.title %>
<% content_for :body_content_left do %>
- <% if @category.posts.any? %>
- <article id="blog_posts">
- <%= render :partial => "/blog/shared/post", :collection => @category.posts %>
- </article>
+ <% if @blog_posts.any? %>
+ <section id="blog_posts">
+ <%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
+ <%= will_paginate @blog_posts %>
+ </section>
<% else %>
<p>
<%= t('.no_posts') %>