socialforge/app/helpers/forums_helper.rb

29 lines
777 B
Ruby
Raw Normal View History

2013-11-22 10:24:15 +08:00
module ForumsHelper
2013-11-26 16:32:08 +08:00
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
2013-11-30 10:46:32 +08:00
# 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')
2013-11-30 10:46:32 +08:00
end
2013-11-22 10:24:15 +08:00
end