Forum: Ruby on Rails Dynamic Menu

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joe C. (Guest)
on 2006-04-21 04:51
Hi, I think I'm doing this the right way, but can't get it going.  I'm
building a menu from the values in a mySQL table, and want to build it
on the fly.  This is something that should be working but only works
halfway:

<% @pages = Page.find(:all, :conditions => ['site_id = 4']) %>
<% @pages.each do |p| %>
	xyz
	<%p.id%>
<% end %>


I know there are two page objects in the array, and the literal in the
loop indeed paints twice, but I can't get p.id to paint anything at all
though.
Adam B. (Guest)
on 2006-04-21 04:57
Joe C. wrote:
> Hi, I think I'm doing this the right way, but can't get it going.  I'm
> building a menu from the values in a mySQL table, and want to build it
> on the fly.  This is something that should be working but only works
> halfway:
>
> <% @pages = Page.find(:all, :conditions => ['site_id = 4']) %>
> <% @pages.each do |p| %>
> 	xyz
> 	<%p.id%>
> <% end %>
>
>
> I know there are two page objects in the array, and the literal in the
> loop indeed paints twice, but I can't get p.id to paint anything at all
> though.

You need an = in Rails tags you want displayed. :)

i.e. <%= p.id %>
Joe C. (Guest)
on 2006-04-21 04:59
Adam B. wrote:
> Joe C. wrote:
>> Hi, I think I'm doing this the right way, but can't get it going.  I'm
>> building a menu from the values in a mySQL table, and want to build it
>> on the fly.  This is something that should be working but only works
>> halfway:
>>
>> <% @pages = Page.find(:all, :conditions => ['site_id = 4']) %>
>> <% @pages.each do |p| %>
>> 	xyz
>> 	<%p.id%>
>> <% end %>
>>
>>
>> I know there are two page objects in the array, and the literal in the
>> loop indeed paints twice, but I can't get p.id to paint anything at all
>> though.
>
> You need an = in Rails tags you want displayed. :)
>
> i.e. <%= p.id %>

Ok thanks, that worked!  Sorry for the stupid question, but I'm up to my
nose in learning curve.
Adam B. (Guest)
on 2006-04-21 05:00
>> You need an = in Rails tags you want displayed. :)
>>
>> i.e. <%= p.id %>
>
> Ok thanks, that worked!  Sorry for the stupid question, but I'm up to my
> nose in learning curve.

It's only stupid the first few times you do it.

By the time you've done it as many times as me, it's
bang-your-head-against-a-wall-dumb.

:D

-Adam
Mohammad R. (Guest)
on 2006-04-21 08:48
Funny, I have a problem of having to change my <%= to <% not the orther
way around, lot eaiser to find the problem :-P
Mohit S. (Guest)
on 2009-05-29 12:50
(Received via mailing list)
Mauricio D. wrote:
> hello, any one know how to make dynamic menu with radiant
>

what do you mean dynamic menu?

Cheers,
Mohit.
5/28/2009 | 11:47 PM.
Sean C. (Guest)
on 2009-05-29 12:51
(Received via mailing list)
Mauricio,

What kind of dynamic menu are you looking to create?  There are lots of
examples out there, some on the wiki:
http://wiki.github.com/radiant/radiant

Sean
Mauricio D. (Guest)
on 2009-05-29 13:04
(Received via mailing list)
if it is possible to create menus that I create content

example

<< Home>>
<< News>CAT1> CAT2*Cat2.1*>
<<Contact>>
Sean C. (Guest)
on 2009-05-29 15:26
(Received via mailing list)
Mauricio -

This is pretty typical problem.  I would structure your site like so:

Home
+- News
|  +- CAT1
|  +- CAT2
|     +- Cat2.1
+- Contact

To generate that navigation menu, you would essentially loop through the
children of "Home", and their children, and so on until you've reached
the maximum depth you want to display.

Sean
Mauricio D. (Guest)
on 2009-05-29 15:39
(Received via mailing list)
OK Seab

thanks LOL
El 28/05/2009, a las 13:22, Sean C.
escribió:
> Mauricio -
This topic is locked and can not be replied to.