Neville,
I didn''t go to the extent of creating my own classes, but I did
something very similar for an application that I''m working on right
now.
I used the "acts_as_tree" and "acts_as_list" properties of
ActiveRecord
to give items in my NavItem table a hierarchy and order. Hieraki uses
this for it''s Chapter menu items as well.
You may find that those two "acts" might work for you and save you
some
work, so if you aren''t familiar with them, do check them out.
--
DeLynn Berry
delynnb-+9FQAZFMD0vCste6SmUHRhL4W9x8LtSr@public.gmane.org
-----Original Message-----
From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On
Behalf Of Neville
Burnell
Sent: Monday, March 14, 2005 11:38 PM
To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: [Rails] Menus / Navigation classes
Hi,
I''ve been thinking of separating my menu/nav ''data''
from its
presentation layer in the view. For example, I''m currently hardcoding
my
menus as a <table> of ''link_to''s, and I''m
thinking of doing something
more flexible to hold the ''menu data'', and pass the
''menu data'' object
to ''render_partial'' which would apply some presentation to
the menu, be
it a top dhtml style thing, or a left column menu etc.
Anyhow, maybe I''m reinventing the wheel. Does anyone have any
comments/pointers to a RoR menu api which I can take advantage of?
Thanks Neville.
psuedo menu code below:
Class MenuItem
def initialize(url, desc)
@url = url
@desc = desc
end
end
Class MenuColumn
def initialize(url, desc)
@url = url
@desc = desc
end
def addItem(menuItem)
@n += 1
@items[n] = menuItem
end
End
Class Menu
def addColumn(menuColumn)
@n += 1
@columns[n] = menuColumn
end
End
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails