-
Notifications
You must be signed in to change notification settings - Fork 2
Customizing navigator
ramontayag edited this page Jun 16, 2011
·
5 revisions
The navigator
is the navigation item or the menu item. I decided to name it navigator because it's the one that sends you to where you want to go (sometimes it points to a navigable
item, sometimes it points to an arbitrary link).
As seen in Installation, there is a minimum amount of fields a navigator
table needs. Here's what they mean:
label
and title
act the same way. You can replace any command below with title
to know how title
works, too.
When you call @nav_item.label
, you will get:
- the value of
label
in the database, if it exists. If it doesn't, - the value of what you have defined as the label in the navigator's navigable.
How? Like so:
class Page << AR::Base
navigable :label => :name
end
@page = Page.create(:name => "About")
@nav_item = @page.to_navigator!
@nav_item.label # "About"
@nav_item.label = "My own label"
@nav_item.label # "My own label"
- will return the link in the database, if it's set. If not,
- will return the
polymorphic_path(navigable)
(show path of the navigable item linked to the navigator).
- will return a regexified version of the string in the database, if it exists:
@nav_item = NavItem.create :highlights_on => "something"
@nav_item.highlights_on # /something/
- if the db value is blank, then
highlights_on
will return the value set in the navigable, without converting it to a regexp.
class Category << AR::Base
navigable :highlights_on => "hi"
end
Category.create.to_navigator.highlights_on # "hi"
These are used by the ordered_tree
gem that navi
uses to form the tree
These are used to make a polymorphic association with the navigables. This is how a nav_item knows where it points.