# How to make a virtual page like '/page/:id'

**URL:** <https://www.ruby-forum.com/t/how-to-make-a-virtual-page-like-page-id/126608>\
**Category:** Radiant CMS\
**Created:** [January 20, 2008, 11:15am UTC](https://www.ruby-forum.com/t/how-to-make-a-virtual-page-like-page-id/126608 "2008-01-20T11:15:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![foobar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@foobar](https://www.ruby-forum.com/u/foobar)\
**Post date:** [January 20, 2008, 11:15am UTC](https://www.ruby-forum.com/t/how-to-make-a-virtual-page-like-page-id/126608/1 "2008-01-20T11:15:11Z")

</div>

While developing my first Radiant site I encountered a problem which  
overwhelms me. Also, I’m not a programmer, so its only worse. Please  
bear  
with me.

First, I tried to make a page “/people” which lists all the people in  
the  
organization. So, I wrote “People” extension (my first), wrote some  
tags,  
and now I can enter a person into the database through the admin  
interface,  
and list every person in the database on the “/people” page. A small  
victory. Unfortunately, it doesn’t end here.

Now I need to display everything there is about a person, but I don’t  
want  
to make a separate child page for each person. I think one page should  
be  
sufficient for that, so a virtual page is in order, right? Well, I tried  
that, and failed miserably. It getting frustrating, since I’ve been  
hanging  
with Google for more then two days now. Either the examples I found are  
too  
complex, or my skull is too thick. At the moment, I’m betting on the  
latter.

So, hopefully, someone has already been there and can show in a simple  
way  
how to achieve what I need to.

Thanks.

---

<div class="post-metadata">

**Author:** ![foobar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@foobar](https://www.ruby-forum.com/u/foobar)\
**Post date:** [January 20, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/how-to-make-a-virtual-page-like-page-id/126608/2 "2008-01-20T20:01:49Z")

</div>

You’re on the right track. The “/people” page should be of a custom  
type that you create so that all child URLs are routed to a single  
virtual child page. I did this for the “Syllabi” at KCKCC over a year  
ago. Here’s a link to the code:

> **[Esumm.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=esumm.com)**
>
> Get this domain name before someone else does. Quick and painless shopping. Affordable payment options available.

Look specifically at the “Syllabi Courses Page” and the “Syllabi  
Prefixes Page”. The “prefixes” page was used as the parent, the  
“courses” page as the virtual child. You can see these in action at:

[http://www.kckcc.edu/academics/course-descriptions/](http://www.kckcc.edu/academics/course-descriptions/)

Cheers,

Sean

---

<div class="post-metadata">

**Author:** ![foobar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@foobar](https://www.ruby-forum.com/u/foobar)\
**Post date:** [January 20, 2008, 8:55pm UTC](https://www.ruby-forum.com/t/how-to-make-a-virtual-page-like-page-id/126608/3 "2008-01-20T20:55:50Z")

</div>

On Jan 20, 2008 8:01 PM, Sean C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://www.kckcc.edu/academics/course-descriptions/](http://www.kckcc.edu/academics/course-descriptions/)

Thanks Sean. To my surprise, somehow I managed to make it work not long  
after clicking on the send button. I also found your extension which  
helped  
somehow, together with the archive extension. Who would say that simply  
stearing long enough at the code you don’t really understand could get  
you  
somewhere. 🙂 My head is spinning, but its fun.

Now I need to make use of model associations. I see the syllabi is  
associated with courses etc, but haven’t found yet how you use it in the  
tags.

---

<div class="post-metadata">

**Author:** ![foobar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@foobar](https://www.ruby-forum.com/u/foobar)\
**Post date:** [January 20, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/how-to-make-a-virtual-page-like-page-id/126608/4 "2008-01-20T23:35:06Z")

</div>

> Thanks Sean. To my surprise, somehow I managed to make it work not long  
> after clicking on the send button. I also found your extension which helped  
> somehow, together with the archive extension. Who would say that simply  
> stearing long enough at the code you don’t really understand could get you  
> somewhere. 🙂 My head is spinning, but its fun.
> 
> Now I need to make use of model associations. I see the syllabi is  
> associated with courses etc, but haven’t found yet how you use it in the  
> tags.

Look in lib/syllabi\_tags.rb for how the majority of the tags are  
defined. Basically, there’s \<r:prefix\>, \<r:courses\>, \<r:syllabi\> tags  
and various others below it. All they do is assist in looping over the  
associations and emitting attributes, really.

Sean

---

<div class="post-metadata">

**Author:** ![foobar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@foobar](https://www.ruby-forum.com/u/foobar)\
**Post date:** [January 22, 2008, 9:17pm UTC](https://www.ruby-forum.com/t/how-to-make-a-virtual-page-like-page-id/126608/5 "2008-01-22T21:17:20Z")

</div>

It sounds like the question was solved, but I just wanted to take a  
moment to plug my DataPages extension:

[http://code.google.com/p/data-pages-extension/](http://code.google.com/p/data-pages-extension/)

Provided you had a way to export your people-data into JSON files (or  
through a respond\_to block in another Rails app’s controller), you  
could make a Virtual Data page for your people directory that  
templates the external data. (See the examples on the wiki.)

The upside of this would be that you wouldn’t have to co-mingle your  
people data with your document data, which is cleaner IMHO. Also, you  
wouldn’t have to implement new Radius tags if your data schema ever  
changes.

-Andrew
