socialforge/app/helpers/forums_helper.rb

23 lines
600 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
end