Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Cms::ContentBucketHelper
- def display_content(content_item, *args)
- case content_item.content_type.to_sym
- when :image
- display_content_image(content_item, *args)
- when :video
- content_tag(:p, "Video has not been implemented.")
- when :audio
- content_tag(:p, "Audio has not been implemented.")
- else
- raise "Don't know how to display content type '#{content_item.content_type}'!"
- end
- end
- def display_content_image(content_item)
- src = content_image_url(content_item)
- "<img id='content_item_img_#{((content_item.is_a? Integer)? content_item: content_item.id)}' src='#{src}' alt='Error displaying content'/>"
- end
- def content_thumbnail_url(content_item, width = nil, height = nil, only_path = true)
- content_image_url(content_item, width, height, "thumbnail", only_path)
- end
- def content_image_url(content_item, width = nil, height = nil, action = "image", only_path = true)
- if content_item.nil?
- elsif content_item.is_a?(Integer)
- content_item_id = content_item
- else
- content_item_id = content_item.id
- end
- parameters = {:controller => "cms/content_bucket",
- :action => action,
- :app_code => params[:app_code],
- :id => content_item_id,
- :only_path => true}
- parameters[:width] = width if !width.nil?
- parameters[:height] = height if !height.nil?
- url_for(parameters)
- end
- end
Add Comment
Please, Sign In to add comment