Class: MostCommentedOnPortlet

Inherits:
Cms::Portlet
  • Object
show all
Defined in:
app/portlets/most_commented_on_portlet.rb

Instance Method Summary collapse

Instance Method Details



7
8
9
10
11
12
13
14
15
16
# File 'app/portlets/most_commented_on_portlet.rb', line 7

def most_popular_pages (limit)
  Cms::Page.find(:all,
            :select => "#{Cms::Page.table_name}.*, COUNT(#{BcmsPageComments::PageComment.table_name}.id) AS comments_count",
            :joins  => "INNER JOIN #{BcmsPageComments::PageComment.table_name} ON #{BcmsPageComments::PageComment.table_name}.page_id = #{Cms::Page.table_name}.id",
            :group  => "#{Cms::Page.table_name}.id",
            :limit => limit,
            :order => "comments_count desc")


end

#renderObject



3
4
5
# File 'app/portlets/most_commented_on_portlet.rb', line 3

def render
  @pages = most_popular_pages(@portlet.number_to_show)
end