# Drop down menus?

**URL:** <https://www.ruby-forum.com/t/drop-down-menus/138771>\
**Category:** Radiant CMS\
**Created:** [May 27, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771 "2008-05-27T16:47:01Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/1 "2008-05-27T16:47:01Z")

</div>

I am new to Radiant and using radiant tags, and I am having trouble  
finding a solution for drop-down menus using r:navigation. What I want  
to do is this, similar to the “suckerfish dropdowns” from [alistapart.com](http://alistapart.com)  
([Suckerfish Dropdowns – A List Apart](http://www.alistapart.com/articles/dropdowns)) :

- Menu Item 1

 ï»¿ - Sub Menu Item 1
 ï»¿ - Sub Menu Item 2
 ï»¿ - Sub Menu Item 3

 ï»¿- Menu Item 2
 ï»¿- Menu Item 3

Are there any facilities for this in r:navigation or do I need to cobble  
this together by hand? Thanks in advance.

~Nate

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/2 "2008-05-27T17:20:47Z")

</div>

Nate,

It depends on how you want to generate those menus. \<r:navigation\> is  
best for single list navigation menus that have highlighting, not nested  
menus. However, assuming you’ll be generating the navigation from the  
page structure, you could do something like this:

\<r:find url="/"\>

- 
  - 

That will generate a list based on the homepage’s children and  
grandchildren pages.

Sean

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 5:29pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/3 "2008-05-27T17:29:04Z")

</div>

On Tue, 2008-05-27 at 10:20 -0500, Sean C. wrote:

> - grandchildren pages.

OMG! Are you kidding me? It’s that easy? I am really loving the switch  
to Radiant.

One question though, I am using r:navigation to show the current page  
with :here and :selected methods(?), so how would this work with the  
markup you described?

~Nate

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 5:45pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/4 "2008-05-27T17:45:35Z")

</div>

There are two tags that you’ll be interested in, and I’ll let you figure  
out where to place them. The first is \<r:if\_self\> which will output its  
contents if the local page (within an iteration) is the same as the  
global page (the one rendering).  
The second is \<r:if\_ancestor\_or\_self\> which will do the same but also  
renders if the local page is an ancestor of the global page. You should  
be able to use these to accomplish the same effect as \<r:here\> and  
\<r:selected\> in the navigation tag.

Sean

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 6:05pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/5 "2008-05-27T18:05:42Z")

</div>

Given that nested list, there are a number of sites that show how to do  
the ‘suckerfish’ pull-downs using ONLY CSS.

Sean C. said the following on 27/05/08 11:20 AM:

> - grandchildren pages. \> 
> - Menu Item 1
> \> this together by hand? Thanks in advance. \>

–  
Many of life’s failures are people who did not realize how close they  
were to success when they gave up.  
Thomas A. Edison

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 7:05pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/6 "2008-05-27T19:05:29Z")

</div>

On Tue, 2008-05-27 at 11:30 -0400, Anton A. wrote:

> Given that nested list, there are a number of sites that show how to do  
> the ‘suckerfish’ pull-downs using ONLY CSS.

Well, only css and a little javascript. My query was about finding the  
most Radiant way to do it. Sean’s solution got me through the list  
generating part, now it’s up to me for the styling. I am aware of the  
various ‘suckerfish’ implementations. What I am not familiar with is the  
radius way to auto-generate the site structure.

~Nate

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 7:15pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/7 "2008-05-27T19:15:31Z")

</div>

> Well, only css and a little javascript. My query was about finding the  
> most Radiant way to do it. Sean’s solution got me through the list  
> generating part, now it’s up to me for the styling. I am aware of the  
> various ‘suckerfish’ implementations. What I am not familiar with is the  
> radius way to auto-generate the site structure.

Nate, Sean’s pointer on the if\_self and if\_self\_or\_ancestor tags is  
key. I have built site map snippets as well as dynamic navigation  
with these. The other possible trick is you can use clever ‘opt out’  
page parts that can remove unwanted pages from this menu. Such as :

\<r:unless\_content part=“no-nav”\>

- \<r:link /\>\<r:if\_ancestor\_or\_self\>…  
\</r:unless\_content\>

In this example any page with a no-nav page part will be ignored. You  
can add these at the top level for things that you don’t want to  
appear in your menu but still be visible in other spaces. You can  
then make a sub-nav snippet that continues to refer to itself so that  
you can nest down many levels. Hopefully that gives you enough to go  
on.

Cheers,  
Marty

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 9:08pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/8 "2008-05-27T21:08:24Z")

</div>

On Tue, 2008-05-27 at 11:14 -0600, Marty H. wrote:

> You can  
> then make a sub-nav snippet that continues to refer to itself so that  
> you can nest down many levels. Hopefully that gives you enough to go  
> on.

You lost me here. I got the no-nav thing, but I don’t understand what  
you would do with a subnav snippet.

~Nate

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 10:50pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/9 "2008-05-27T22:50:10Z")

</div>

Anton A. wrote:

> There **ARE** pure CSS pull-downs.

Anton, I couldn’t get to the link you provided so just in case I wanted  
to make sure you and others were aware that you do need a bit of  
javascript with suckerfish menus if you plan to support IE 6 or lower  
(they only support the pseudo classes (like :hover) on tags so you  
can have javascript “add” attributes to your DOM so the older IE’s can  
play along).

 

If your requirements are only for newer browsers, then you can get by  
with true css-only drop down menus.

 

-Chris

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2008, 9:35pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/10 "2008-05-27T21:35:41Z")

</div>

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) said the following on 27/05/08 01:05 PM:

> On Tue, 2008-05-27 at 11:30 -0400, Anton A. wrote:
> 
> > Given that nested list, there are a number of sites that show how to do  
> > the ‘suckerfish’ pull-downs using ONLY CSS.
> 
> Well, only css and a little javascript.

There **ARE** pure CSS pull-downs.  
I’ve always preferred them to the javascript ones for a variety of  
reasons, not least of which is that the ones I’ve used (go google) are  
portable across browsers and work when javascript is turned off, as many  
people do thinking that this makes them immune to things like XSS.

Her, for example, is a CSS generator with which you can even customize  
the CSS

[http://pixopoint.com/suckerfish\_css/](http://pixopoint.com/suckerfish_css/)

–  
“Democracy” is a system that allows those who are directly affected by  
decisions to exert some influence on the decision makers,

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 10, 2009, 10:52pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/11 "2009-01-10T22:52:52Z")

</div>

Hi!

I don’t know exactly what you’re looking for… The navigation that  
you describe below is only one level (with no sub categories), for  
that using a dropdown menu isn’t all that common. Anyways dropdowns  
are most commonly achieved using CSS (see  
[Suckerfish Dropdowns – A List Apart](http://www.alistapart.com/articles/dropdowns))  
to style a unordered list (just like the code Sean C. gave you  
would have done). However, it seems like you’d rather specify the menu  
items manually (Sean’s code would automatically have created the  
navigation based on your site three).

If you manually want to specify the navigation I’d recommend using the  
\<r:navigation\> tag. In general I’d suggest that you look through the  
comments in the Radiant code for more in depth explanations, since the  
wiki documentation isn’t all that complete:

> <https://github.com/radiant/radiant/blob/master/app/models/standard_tags.rb>

Don’t know exactly what you needed to know, but hope this helps. Good  
luck!

cheers, Simon

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 10, 2009, 11:24pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/12 "2009-01-10T23:24:42Z")

</div>

> I don’t know exactly what you’re looking for… The navigation that  
> you describe below is only one level (with no sub categories), for  
> that using a dropdown menu isn’t all that common. Anyways dropdowns  
> are most commonly achieved using CSS (see  
> [Suckerfish Dropdowns – A List Apart](http://www.alistapart.com/articles/dropdowns))  
> to style a unordered list (just like the code Sean C. gave you  
> would have done). However, it seems like you’d rather specify the menu  
> items manually (Sean’s code would automatically have created the  
> navigation based on your site three).
> 
> cheers, Simon

Sounds like I’m making this harder than need be. I would prefer to have  
it created dynamically based on the site tree. I have all the pages in  
order and parent/child relationships are correct.

If I understand you correctly, I should swamp my existing code with  
Sean’s and that should get me moving in the right direction?

Thanks for the input, Simon

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 11, 2009, 1:28am UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/13 "2009-01-11T01:28:37Z")

</div>

Hi!

Yes, if you want it made up automatically then go with Sean’s code…  
and to make that into a drop-down use this:

> **[Suckerfish Dropdowns](https://alistapart.com/article/dropdowns/)**
>
> Teach your smart little menus to do the DHTML dropdown dance without sacrificing semantics, accessibility, or standards compliance or writing clunky code.

(the article has nothing to do with Radiant, it’s just about CSS…  
but Sean’s code does the Radiant part)

Don’t know how much experience you have with CSS, but I guess you’ll  
be fine with that article. Good luck!

cheers, Simon

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 10, 2009, 9:11pm UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/14 "2009-01-10T21:11:55Z")

</div>

I am also VERY new to Radiant and my first project has a painfully tight  
deadline requiring dynamic drop downs. I have a bout 48 hours to figure  
this out and have reached extreme frustration with the wiki  
documentation.

I understand and appreciate the simplicity of Sean’s contribution below:

Sean C. wrote:

> \<r:find url=“/”\>
> 
> - 
> -

My issues is figuring out how to apply it to my site. I currently have  
the main navigation in a snippet that is called from the Normal Layout.  
All but two of the main menu items required drop downs. The code I am  
currently using is below:

\<r:link\>HOME\</r:link\>|  
\<r:link\>[ABOUT THE TOUR](https://www.ruby-forum.com/about-the-tour/)\</r:link\>|  
\<r:link\>[RIDER AREA](https://www.ruby-forum.com/rider-area/)\</r:link\>|  
\<r:link\>[OUR PARTNERS](https://www.ruby-forum.com/our-partners/)\</r:link\>|  
\<r:link\>[POST-NEWS  
COMMUNITY](https://www.ruby-forum.com/post-news-community/)\</r:link\>|  
\<r:link\>[MEDIA ROOM](https://www.ruby-forum.com/media-room/)\</r:link\>|  
\<r:link\>[ABOUT US](https://www.ruby-forum.com/about-us/)\</r:link\>

Hate to be so publicly naive, but would be extremely grateful for any  
assistance.

-Kelly

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 11, 2009, 4:38am UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/15 "2009-01-11T04:38:50Z")

</div>

I would suggest the “Son of Suckerfish” for building the drop downs. It  
uses  
some javascript, but is compatible with just about every recent (or not  
so  
recent in the case of IE6) browser. It’s the place I start for dropdowns  
when I have to use them.

~Nate

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 11, 2009, 4:43am UTC](https://www.ruby-forum.com/t/drop-down-menus/138771/16 "2009-01-11T04:43:32Z")

</div>

I forgot…

Son of Suckerfish: [Son of Suckerfish Dropdowns](http://htmldog.com/articles/suckerfish/dropdowns/)

If you are putting flash on a page you should be worried about using 12  
lines of js.

~Nate
