I''m working on a simple photo gallery app for personal use and I want
to
generalize the sidebar such that in any page (controller or view, I''m
not sure which) I can dynamically add either
1. links to a given sidebar
2. or an entire sidebar.
I know that typo does this, and I''ve looked the code. I think
it''s too
complex a solution for my simple site. I''d like to avoid using
components, and make do with a bit of code in the layout and maybe a
partial and a helper or something.
Here''s the code that''s in my sidebar now.
<div id="sidebar">
<div id="controls" class="sidebar-node">
<h3>Pictures</h3>
<ul>
<li><%= link_to "Refresh Pictures", { :action =>
''scan_directory''}, :confirm => "Are you
sure?"%>
<li><%= link_to "All Pictures", { :action =>
''list'' } %>
</ul>
</div><!-- #sidebar -->
Now lets say I want to take out those 2 links and specifying them from,
say, my list.rhtml page. How would I go about it?
I was thinking of creating a literal array of links, then using a
partial that loops over the array with an <li> for each one.
Does that sound easiest?
Whats the best way to put the link info in an array? Could I make an
array of the html result of the link_to calls themselves?
Or maybe an array of literal hashes of the arguments to link_to?
Or do I need to make my own structure?
How do other apps, outside of typo, deal with dynamic sidebars? Or
toolbars for that matter - it''s more a toolbar than a sidebar really.
--
Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Mar-28 15:59 UTC
[Rails] Simple Sidebar Solutions: How does yours work?
Components really aren''t all that hard, but... You could put a instance variable in the correct spot like... <div id="sidebar"> <%= @sidebar %> </div> And then have each controller set the varible @sidebar in a before_filter _Kevin On Tuesday, March 28, 2006, at 3:55 PM, rhubarb wrote:>I''m working on a simple photo gallery app for personal use and I want to >generalize the sidebar such that in any page (controller or view, I''m >not sure which) I can dynamically add either >1. links to a given sidebar >2. or an entire sidebar. > >I know that typo does this, and I''ve looked the code. I think it''s too >complex a solution for my simple site. I''d like to avoid using >components, and make do with a bit of code in the layout and maybe a >partial and a helper or something. > >Here''s the code that''s in my sidebar now. > ><div id="sidebar"> ><div id="controls" class="sidebar-node"> ><h3>Pictures</h3> ><ul> > <li><%= link_to "Refresh Pictures", { :action => >''scan_directory''}, :confirm => "Are you sure?"%> > <li><%= link_to "All Pictures", { :action => ''list'' } %> ></ul> ></div><!-- #sidebar --> > >Now lets say I want to take out those 2 links and specifying them from, >say, my list.rhtml page. How would I go about it? > >I was thinking of creating a literal array of links, then using a >partial that loops over the array with an <li> for each one. >Does that sound easiest? > >Whats the best way to put the link info in an array? Could I make an >array of the html result of the link_to calls themselves? >Or maybe an array of literal hashes of the arguments to link_to? >Or do I need to make my own structure? > >How do other apps, outside of typo, deal with dynamic sidebars? Or >toolbars for that matter - it''s more a toolbar than a sidebar really. > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails-- Posted with http://DevLists.com. Sign up and save your time!