博客列表修改

This commit is contained in:
yuanke 2016-04-21 09:39:21 +08:00
parent 29115bca3a
commit 85055f2a84
3 changed files with 25 additions and 3 deletions

View File

@ -4,12 +4,20 @@ class BlogsController < ApplicationController
def index
@article = BlogComment.new
@topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.updated_on desc")
@order, @b_sort = params[:order] || 1, params[:sort] || "desc"
sort_name = @order == 1 ? "created_on" : ""
@topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{@b_sort}")
#分页
@topics = paginateHelper @topics,10
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html {render :layout=>'new_base_user'}
end
@ -62,4 +70,8 @@ class BlogsController < ApplicationController
def find_user
@user = User.find(params[:user_id])
end
def blogsort
end
end

View File

@ -2,8 +2,18 @@
<h2 class="list-h2">博客列表</h2>
<div class="category">
<span class="grayTxt ">排序:</span>
<a href="#" class="sortTxt ">时间</a><a class="sortupbtn "></a>
<a href="#" class="sortTxt ">人气</a><a class="sortdownbtn "></a>
<%= link_to "时间", user_blog_sort_blog_path(:sort => @score, :order => 1, :search => " "), :class => "sortTxt", :remote => true %>
<% if @order == 1 %>
<%= link_to "", user_blog_sort_blog_path(:sort => @score, :order => 1, :search => " "), :class => "#{@score == 'desc' ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
<%= link_to "人气", user_blog_sort_blog_path(:sort => @score, :order => 2, :search => " "), :class => "sortTxt", :remote => true %>
<% if @order == 2 %>
<%= link_to "", user_blog_sort_blog_path(:sort => @score, :order => 2, :search => " "), :class => "#{@score == 'desc' ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
<div class="cl"></div>
</div>
<div class="bloglistbox">

View File