Ruby Forum Radiant CMS > Overriding front-end URL routing

Posted by David Piehler (davidpiehler)
on 24.04.2008 16:49
Hello,

I have a few sections in a client project that are buried a bit deep,
which creates longer-than-desired URLs...

home
- about
-- newsroom
--- press
--- announcements
--- events

The Press section URLs looks like this...
/about/newsroom/press/
/about/newsroom/press/article-name/

Is there any way to override this and have tags for these third-level
sections output and resolve to URLs like...
/press/
/press/article-name/

I could simply move these sections to be root-level, but I'd like to
avoid that if possible for a few reasons.

Thanks,
- Dave
Posted by Sean Cribbs (seancribbs)
on 24.04.2008 17:03
(Received via mailing list)
David,

You could create a special Page type that acts like a rewrite rule,
redefining find_by_url so that it scopes to your "buried" page.  If you
want to go the simple route, you could rewrite the URL in your webserver
before it gets to Radiant, but that would be uneditable from the Radiant
interface.

Sean
Posted by David Piehler (davidpiehler)
on 24.04.2008 22:21
Sean Cribbs wrote:
> You could create a special Page type that acts like a rewrite rule,
> redefining find_by_url so that it scopes to your "buried" page.  If you
> want to go the simple route, you could rewrite the URL in your webserver
> before it gets to Radiant, but that would be uneditable from the Radiant
> interface.

Thanks for the ideas Sean. Using mod_rewrite would definitely be the 
easier route, but the in-page URLs created by the radius tags would 
still appear as "/about/newsroom/press/article-name/"... Though I could 
just use custom hrefs instead of using r:link...
Posted by Arik Jones (imakethings)
on 25.04.2008 10:55
In this case you'd honestly be better off creating a press page at the 
root-level and then calling in the children of newsroom/press. Its 
really difficult to avoid long urls when it comes to news, blog or 
chronologically added pages. I'd consider this a fringe case simply 
cause most people don't really find it necessary to manually type in 
long or even pretty urls. Your call. :)

David Piehler wrote:
> Sean Cribbs wrote:
>> You could create a special Page type that acts like a rewrite rule,
>> redefining find_by_url so that it scopes to your "buried" page.  If you
>> want to go the simple route, you could rewrite the URL in your webserver
>> before it gets to Radiant, but that would be uneditable from the Radiant
>> interface.
> 
> Thanks for the ideas Sean. Using mod_rewrite would definitely be the 
> easier route, but the in-page URLs created by the radius tags would 
> still appear as "/about/newsroom/press/article-name/"... Though I could 
> just use custom hrefs instead of using r:link...
Posted by David Piehler (davidpiehler)
on 25.04.2008 17:47
Arik Jones wrote:
> In this case you'd honestly be better off creating a press page at the 
> root-level and then calling in the children of newsroom/press. Its 
> really difficult to avoid long urls when it comes to news, blog or 
> chronologically added pages. I'd consider this a fringe case simply 
> cause most people don't really find it necessary to manually type in 
> long or even pretty urls. Your call. :)

I'd agree that this is definitely a fringe case. I think if my client 
really wants to be able to advertise URLs like website.com/press then I 
can simply do some mod_rewrite stuff to rewrite that to the actual URL.

Thanks for the input on this guys!

- Dave