博客列表修改
This commit is contained in:
parent
29115bca3a
commit
85055f2a84
|
@ -4,12 +4,20 @@ class BlogsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@article = BlogComment.new
|
@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
|
@topics = paginateHelper @topics,10
|
||||||
@page = (params['page'] || 1).to_i - 1
|
@page = (params['page'] || 1).to_i - 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :layout=>'new_base_user'}
|
format.html {render :layout=>'new_base_user'}
|
||||||
end
|
end
|
||||||
|
@ -62,4 +70,8 @@ class BlogsController < ApplicationController
|
||||||
def find_user
|
def find_user
|
||||||
@user = User.find(params[:user_id])
|
@user = User.find(params[:user_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def blogsort
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,18 @@
|
||||||
<h2 class="list-h2">博客列表</h2>
|
<h2 class="list-h2">博客列表</h2>
|
||||||
<div class="category">
|
<div class="category">
|
||||||
<span class="grayTxt ">排序:</span>
|
<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 class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bloglistbox">
|
<div class="bloglistbox">
|
||||||
|
|
Loading…
Reference in New Issue