Class: RecentNewsPortlet

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

Instance Method Summary collapse

Instance Method Details

#articlesObject

For testing



26
27
28
# File 'app/portlets/recent_news_portlet.rb', line 26

def articles
  @articles
end

#attributesObject

For testing



31
32
33
# File 'app/portlets/recent_news_portlet.rb', line 31

def attributes
  @portlet
end

#categoryObject



21
22
23
# File 'app/portlets/recent_news_portlet.rb', line 21

def category
  @category
end

#renderObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/portlets/recent_news_portlet.rb', line 6

def render
  order = "release_date DESC"
  if !attributes.sort_by.blank? and !attributes.sort_order.blank?
    order = "#{attributes.sort_by} #{attributes.sort_order}"
  end

  if attributes.category_id.blank?
    @articles = BcmsNews::NewsArticle.released.all(:order => order, :limit => attributes.limit)
  else
    @category = Cms::Category.find(attributes.category_id)
    @articles = BcmsNews::NewsArticle.released.all(:conditions => ["category_id = ?", @category.id], 
        :order => order, :limit => attributes.limit)
  end
end