socialforge/app/helpers/forums_helper.rb

29 lines
777 B
Ruby

module ForumsHelper
def forum_breadcrumb(item)
forum = item.is_a?(Memo) ? item.forum : item
links = [link_to(l(:label_forum_plural), forums_path(item))]
forums = forum.ancestors.reverse
if item.is_a?(Memo)
forums << forum
end
links += forums.map {|ancestor| link_to(h(ancestor.name), forum_path(ancestor))}
breadcrumb links
end
def forums_options_for_select(forums)
options = []
Forum.forum_tree(forums) do |forum, level|
label = (level > 0 ? '&nbsp;' * 2 * level + '&#187; ' : '').html_safe
label << forum.name
options << [label, forum.id]
end
options
end
# this method is used to get all projects that tagged one tag
# added by william
def get_forums_by_tag(tag_name)
Forum.tagged_with(tag_name).order('updated_at desc')
end
end