danielvlopes / has_breadcrumbs forked from fnando/has_breadcrumbs

has_breadcrumbs is a simple plugin that adds a `breadcrumb` object into controllers and views.

This URL has Read+Write access

name age message
file MIT-LICENSE Loading commit data...
file README.textile
directory examples/
file init.rb
directory lib/
directory spec/
README.textile

has_breadcrumbs

has_breadcrumbs is a simple plugin that adds a breadcrumb object into controllers and views.

Instalation

1) Install the plugin with `script/plugin install git://github.com/danielvlopes/has_breadcrumbs.git`

Usage

On your controller:

class ApplicationController < ActionController::Base
	before_filter :add_initial_breadcrumbs

	private
		def add_initial_breadcrumbs
			breadcrumb.add 'Home', root_path
		end
end

class ThingsController < ApplicationController
	def index
		breadcrumb.add 'Things', things_path
	end
end

You don’t need to provide an URL; in that case, a span will be generated
instead of a link:

breadcrumb.add 'Some page'

You can set additional HTML attributes if you need to:

breadcrumb.add 'Home', root_path, :id => 'home', :title => 'Go to the home page'

On your view (possibly application.html.erb):

You are here: <%= breadcrumb.display %>

You can set your own separator:

You are here: <%= breadcrumb.display %>

The output in your html will be something like below:

	<ul id="breadcrumbs">
		<li class="item-0"><a href="#">Home</a></li>
		<li class="item-1"><a href="#">Main section</a></li>
		<li class="item-2"><a href="#">Sub section</a></li>
		<li class="item-3 last">The page you are on right now</li>
	</ul>

For a good css example take a look in examples folder.

This work is based on http://github.com/fnando/has_breadcrumbs/tree/master by Nando Vieira.

This adaptation is maded by Daniel Lopes, and still under the MIT license.