Sha256: e975b29309a45f014c660887bda1158dd48d546b19a0134730366ecbd977e895

Contents?: true

Size: 845 Bytes

Versions: 2

Compression:

Stored size: 845 Bytes

Contents

module Wobapphelpers
  module Breadcrumbs
    module BreadcrumbsHelper
      def render_breadcrumbs
	return if Wobapphelpers.breadcrumb_controller_blacklist.include?(controller.controller_path)
	return if session[:breadcrumbs].nil? || session[:breadcrumbs].size == 0
	track = ""
	session[:breadcrumbs].each_with_index do |b, idx|
	  track += "> #{breadcrumb_idx(b[0], b[1], idx)} "
	end
	%Q[<div id="breadcrumbs" class="visible-desktop">#{track}</div>].html_safe
      end

      def breadcrumb_idx(name, url, idx, html_class=nil)
        uri = URI.parse(url)
        query = uri.query || ""
        if query =~ /bci=(\d+)/
          uri.query.gsub!(/bci=(\d+)/, "bci=#{idx}")
        else
          uri.query = query + "&bci=#{idx}"
        end
        link_to name, uri.to_s.gsub('?&','?'), :class => html_class
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wobapphelpers-3.1.1 lib/wobapphelpers/breadcrumbs/breadcrumbs_helper.rb
wobapphelpers-3.1.0 lib/wobapphelpers/breadcrumbs/breadcrumbs_helper.rb