summaryrefslogtreecommitdiff
path: root/app/helpers/link_helper.rb
blob: 3be5953a6859256e23886b3ab37af6c1fba02079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module LinkHelper
  
  def link_to_path title, path, html_options = {}
    active = (params[:page_path].join("/") == path.sub(/^\//, ""))
    
    params[:locale] ||= I18n.locale
    
    link_to( 
      title, {
        :controller => :content,
        :action => :render_page,
        :locale => params[:locale],
        :page_path => path.sub(/^\//, "").split("/")
      },
      active ? {:class => 'active'} : {:class => 'inactive'}
    )
  end
  
  def selected? controller_name
    if params[:controller] == controller_name
      return :class => "selected"
    end
  end
end