# Extending

**URL:** <https://www.ruby-forum.com/t/extending/85126>\
**Category:** Radiant CMS\
**Created:** [February 10, 2007, 6:55am UTC](https://www.ruby-forum.com/t/extending/85126 "2007-02-10T06:55:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bueller](https://www.ruby-forum.com/u/bueller)\
**Post date:** [February 10, 2007, 6:55am UTC](https://www.ruby-forum.com/t/extending/85126/1 "2007-02-10T06:55:36Z")

</div>

So i am trying to make a way to list the previous articles in a list  
format not by date or month but simply by order published, also be able  
to break that up into multiple pages (page one is 12 articles page 2 is  
12 and so on) in a dynamic fashion. I have tried to modify the  
\<r:children:each limit=“12” offset=“12” order=“desc”\>  
tag to accept a passed variable that tells it what the current offset is  
but that has been to no avail i dont care if its by passing a variable  
or by using tags or making a new behavior i just want a simple page that  
lists all my articles in order dynamically allocating how many articles  
can be viewed per page

---

<div class="post-metadata">

**Author:** ![bueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bueller](https://www.ruby-forum.com/u/bueller)\
**Post date:** [February 10, 2007, 8:27am UTC](https://www.ruby-forum.com/t/extending/85126/2 "2007-02-10T08:27:08Z")

</div>

bueller wrote:

> So i am trying to make a way to list the previous articles in a list  
> format not by date or month but simply by order published, also be able  
> to break that up into multiple pages (page one is 12 articles page 2 is  
> 12 and so on) in a dynamic fashion. I have tried to modify the  
> \<r:children:each limit=“12” offset=“12” order=“desc”\>  
> tag to accept a passed variable that tells it what the current offset is  
> but that has been to no avail i dont care if its by passing a variable  
> or by using tags or making a new behavior i just want a simple page that  
> lists all my articles in order dynamically allocating how many articles  
> can be viewed per page

have you tried mucking with definition of the r:children tag?

are you using trunk or mental?

---

<div class="post-metadata">

**Author:** ![bueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bueller](https://www.ruby-forum.com/u/bueller)\
**Post date:** [February 10, 2007, 5:05pm UTC](https://www.ruby-forum.com/t/extending/85126/3 "2007-02-10T17:05:22Z")

</div>

> > I have tried to modify the  
> > \<r:children:each limit=“12” offset=“12” order=“desc”\>  
> > tag to accept a passed variable that tells it what the current offset is

Assuming you are using mental, apply this diff to site\_controller.rb:

# Index: site\_controller.rb

— site\_controller.rb (revision 326)  
+++ site\_controller.rb (working copy)  
@@ -13,11 +13,12 @@  
def show\_page  
response.headers.delete(‘Cache-Control’)  
url = params[:url].to\_s

- if live? and (@cache.response\_cached?(url))

- extra\_params = params.reject{ | key, value | [‘action’,  
‘controller’, ‘url’].include? key }
- if live? and (@cache.response\_cached?(url)) and extra\_params.empty?  
@cache.update\_response(url, response)  
@performed\_render = true  
else

- 

```
 show_uncached_page(url)

```

- 

```
 show_uncached_page(url, false)

```

end  
end

@@ -28,11 +29,11 @@  
found if found and (found.published? or dev?)  
end

- def show\_uncached\_page(url)

- def show\_uncached\_page(url, cache\_result=true)  
@page = find\_page(url)  
unless @page.nil?  
@page.process(request, response)

- 

```
   @cache.cache_response(url, response) if live? and @page.cache?

```

- 

```
   @cache.cache_response(url, response) if live? and @page.cache? 

```

and cache\_result  
@performed\_render = true  
else  
render :template =\> ‘site/not\_found’, :status =\> 404

This will change site\_controller so that any reuqest containing url  
parameters ?like=this&and=that will not be cached.

Now, you can reference the request parameters from within your tags:

here’s an example that just prints out the parameters:

desc %{  
hi  
}  
tag ‘hi’ do |tag|  
out = “”  
tag.globals.page.request.params.each do  
| param |  
out += param[0].to\_s + ": " + param[1].to\_s + "   
 "  
end  
out  
end

John (and Core)  
I tried to submit my diff as a ticket to Trac, but I don’t see any way  
of uploading it via new ticket… what am i missing?

---

<div class="post-metadata">

**Author:** ![bueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bueller](https://www.ruby-forum.com/u/bueller)\
**Post date:** [February 10, 2007, 6:08pm UTC](https://www.ruby-forum.com/t/extending/85126/4 "2007-02-10T18:08:47Z")

</div>

> Each of the apparent child pages of that page are actually a single  
> virtual page that uses the passed URL to determine which collection of  
> models to display.

So you are using a custom page type for that?  
Can I see the source please? : )

---

<div class="post-metadata">

**Author:** ![bueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bueller](https://www.ruby-forum.com/u/bueller)\
**Post date:** [February 10, 2007, 6:11pm UTC](https://www.ruby-forum.com/t/extending/85126/5 "2007-02-10T18:11:34Z")

</div>

Yes, remind me on Monday. I don’t have access to our SVN from home.

Sean

---

<div class="post-metadata">

**Author:** ![bueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bueller](https://www.ruby-forum.com/u/bueller)\
**Post date:** [February 10, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/extending/85126/6 "2007-02-10T17:21:31Z")

</div>

bueller wrote:

> 

You have the right idea. Can you paste more of the Radius code that  
you’re using? I don’t think it’s necessary to change the SiteController  
to do what you want. The easiest way I’ve found to do what you’re  
saying is to create virtual pages. For one page type I constructed for  
kckcc.edu, I mimiced the find\_page\_by\_url functionality of the  
ArchivePage, then returned a virtual subpage that was capable of  
handling the request. I used this to handle a custom model, but the same  
could be done for pages. Here’s the URL:

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

Each of the apparent child pages of that page are actually a single  
virtual page that uses the passed URL to determine which collection of  
models to display.

Sean

---

<div class="post-metadata">

**Author:** ![bueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bueller](https://www.ruby-forum.com/u/bueller)\
**Post date:** [February 10, 2007, 9:56pm UTC](https://www.ruby-forum.com/t/extending/85126/7 "2007-02-10T21:56:09Z")

</div>

Sean C. wrote:

> Each of the apparent child pages of that page are actually a single  
> virtual page that uses the passed URL to determine which collection of  
> models to display.
> 
> Sean  
> i agree but the problem is i have no idea how to get the params passed  
> into the tag…going to try what is posted above but im scared about  
> that because he said i need mental for that code to work…is there a  
> tags.globas.request.params or something like that i am missing? so close  
> but so far

---

<div class="post-metadata">

**Author:** ![bueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc79bd/32.png) [@bueller](https://www.ruby-forum.com/u/bueller)\
**Post date:** [February 10, 2007, 9:49pm UTC](https://www.ruby-forum.com/t/extending/85126/8 "2007-02-10T21:49:05Z")

</div>

Jacob B. wrote:

> Assuming you are using mental, apply this diff to site\_controller.rb:

unfortunately i am using trunk (5.2.2) i am using bluehost to host and i  
couldnt get mental to run on them, i am praying that this example you  
showed me might help with trunk anyways.

I am going to my other computer in a few hours and i will try to use  
this, if you have a version of this that definitely works for trunk id  
love you even more im pretty noob overall when it comes to ruby but im  
starting to get the hang of it.

Thanks everyone for trying to help me out with this i have to say i will  
stick by radiant and do what i can to help indefinitely!
