Class: ContentRotatorPortlet

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

Instance Method Summary collapse

Instance Method Details

#renderObject



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

def render

  # Collect the list of slide_ids
  @slide_ids = []
  (1..5).each do |i|
    s_id = self.send("slide_#{i}_id")
    @slide_ids << s_id.to_i if (s_id && !s_id.empty?)
  end

  unsorted_slides = BcmsContentRotator::Slide.find(@slide_ids)

  # Sort slides into explicit order based on slide_ids
  @slides = []
  @slide_ids.each do |id|
    @slides << unsorted_slides.select{|item| item.id == id}.first
  end
end