# Table of contents snippet help

**URL:** <https://www.ruby-forum.com/t/table-of-contents-snippet-help/75657>\
**Category:** Radiant CMS\
**Created:** [November 12, 2006, 12:17am UTC](https://www.ruby-forum.com/t/table-of-contents-snippet-help/75657 "2006-11-12T00:17:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ambitiouslemon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@ambitiouslemon](https://www.ruby-forum.com/u/ambitiouslemon)\
**Post date:** [November 12, 2006, 12:17am UTC](https://www.ruby-forum.com/t/table-of-contents-snippet-help/75657/1 "2006-11-12T00:17:00Z")

</div>

I’ve been trying to make a simple Table of Contents snippet that would  
create a table of contents for a FAQ system where questions fall into  
categories and each category and question is a page in the admin  
interface (though the individual questions would all be listed in full  
on the category page).

What I have so far is:  
\<r:parent\>

“\<r:title/\>”:\<r:url/\>  
\<r:children:each\>

- “\<r:title/\>”:\<r:url/\>

\</r:children:each\>

Category pages look like:  
\<r:children:each\>

```
        <h2><r:title/></h2>

        <r:content/>
      </r:children:each>

```

The only trouble I am having is that I want the second level contents  
(the children of the child listed) to only be listed if that child is  
currently active. Its simple to have the children (questions) of all  
categories visible, but I only want the children of the active category  
to be visible.

So if my directory structure is:  
-FAQ  
–why  
—why am i so lame?  
—why do i always need help?  
–how  
—how will i find help?  
—how will this all end up?

…and my currently active page is the “how” category page then I want  
my table of contents to read:

- why
- how  
–how will i find help?  
–how will this all end up?

So the table of contents is hiding the children of the other sections.

Any advice on how to do this with the current tags or with a custom tag  
would be appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![ambitiouslemon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@ambitiouslemon](https://www.ruby-forum.com/u/ambitiouslemon)\
**Post date:** [November 12, 2006, 8:37pm UTC](https://www.ruby-forum.com/t/table-of-contents-snippet-help/75657/2 "2006-11-12T20:37:59Z")

</div>

This is what I came up with. Its not ideal because its less automated  
than I wanted. I have to add an extra if\_url section for every category  
I create.

\<r:if\_url matches="./\*faq/$"\>

h2. Table of Contents:

- "":: ()

\</r:if\_url\>

\<r:if\_url matches="./\*faq/category-1/$"\>

h2. Table of Contents:

- "":: () 
  - "":#

- "":: ()

h2. Table of Contents:

- "":: () 
  - "":#

- "":: ()

h2. Table of Contents:

- "":: () 
  - "":#

- "":: ()

h2. Table of Contents:

- "":: () 
  - "":#

- "":: ()

Any ideas on how to have it automatically cycle through each of the  
categories rather than my having to create it manually?

---

<div class="post-metadata">

**Author:** ![ambitiouslemon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@ambitiouslemon](https://www.ruby-forum.com/u/ambitiouslemon)\
**Post date:** [November 12, 2006, 9:37pm UTC](https://www.ruby-forum.com/t/table-of-contents-snippet-help/75657/3 "2006-11-12T21:37:12Z")

</div>

Hi,

I’ve set up a radiant site and it works fine on Firefox and Epiphany,  
however when on Internet Explorer 6-7 the site doesn’t render instead it  
forces a save as prompt for the main html page.

The problem persists running the site with Webrick, Mongrel, and Apache  
FCGI.

I’ve another radiant site running Webbrick and it renders fine on IE.  
What  
could be the problem then? I’ve reinstalled radiant and nothing. How  
could  
I figure out what’s wrong?

Jose.

---

<div class="post-metadata">

**Author:** ![ambitiouslemon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@ambitiouslemon](https://www.ruby-forum.com/u/ambitiouslemon)\
**Post date:** [November 12, 2006, 11:09pm UTC](https://www.ruby-forum.com/t/table-of-contents-snippet-help/75657/4 "2006-11-12T23:09:30Z")

</div>

Can you just create a FAQ controller (and behaviour) and have the url  
encode  
the arguments? Even though your solution _works,_ it violates DRY…BIG  
TIME!

---

<div class="post-metadata">

**Author:** ![ambitiouslemon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@ambitiouslemon](https://www.ruby-forum.com/u/ambitiouslemon)\
**Post date:** [November 12, 2006, 11:28pm UTC](https://www.ruby-forum.com/t/table-of-contents-snippet-help/75657/5 "2006-11-12T23:28:20Z")

</div>

Ruben D. Orduz wrote:

> Can you just create a FAQ controller (and behaviour) and have the url  
> encode  
> the arguments? Even though your solution _works,_ it violates DRY…BIG  
> TIME!

I’m a css/html guy, don’t know any rails. I was hoping someone could  
point me in the right direction though.

---

<div class="post-metadata">

**Author:** ![ambitiouslemon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@ambitiouslemon](https://www.ruby-forum.com/u/ambitiouslemon)\
**Post date:** [November 12, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/table-of-contents-snippet-help/75657/6 "2006-11-12T22:57:28Z")

</div>

Hi,

Ok. When I remove the utf-8 declaration from the Normal layout More  
Content-Type tab the page does display in Internet Explorer 5.0, 5.5,  
and  
6.0. However, the page’s layout appears very distorted. At least now  
it’s  
a matter of css.

Has anybody experienced similar problems?

jose.
