Preroute interception point.

0 views
Skip to first unread message

Joe

unread,
Jul 25, 2010, 12:56:33 PM7/25/10
to ColdMVC
I want to intercept the route before it goes through route handling
and I can't find away to do it.

I am trying to create a cms app with ColdMVC and I have a page object
with a property called "address" on in it. Example "products/". My
plan is to append the address to the link. Example
www.myDomain.com/public/index.cfm/products/. My goal is to check if
the address exists in a page object and if it does, to NOT execute the
routeHandling and allow me to intercept the request and handle it.

I tried to make a route like this :
<cfset add(":action", {
default= {
controller = "cmsView",
action="render"
}
}) />

But the default route for forms in ColdMVC gets replaced by this one,
so my forms break.

Next I tried invalidController and invalidAction, but the event view
key gets jacked up so I try to parse the address. It ends up looking
like this /products/.cfm...which is kinda funky.

CMSViewController.cfc
/**
* @events invalidController, invalidAction
*/
function render(){

params.page =
_CMSPage.findByAddress(trim(replaceNoCase($.event.get().view,".cfm","/","all")));

params.html = params.page.html();

$.event.action("view");
$.event.controller("cmsView");
$.event.view("/cms/index.cfm");
}

Any ideas on how I could capture the request and handle it before the
route handling kicks in?

Tony Nelson

unread,
Jul 25, 2010, 1:43:35 PM7/25/10
to ColdMVC
You could try using @requestStart to change the event's value before
the routeHandler dispatches the event. We previously discussed
something similar in a previous thread found here:
http://groups.google.com/group/coldmvc/msg/f3718294a4776523

-Tony

On Jul 25, 11:56 am, Joe <jban...@gmail.com> wrote:
> I want to intercept the route before it goes through route handling
> and I can't find away to do it.
>
> I am trying to create a cms app with ColdMVC and I have a page object
> with a property called "address" on in it. Example "products/". My
> plan is to append the address to the link. Examplewww.myDomain.com/public/index.cfm/products/. My goal is to check if

Joe

unread,
Jul 26, 2010, 10:07:36 AM7/26/10
to ColdMVC
Nice. I ended up using @events requestStart
/**
* @events requestStart
*/
function requestStart(){

params.path = routeHandler.parseURL();

if(left(params.path,1) eq "/"){
params.path = right(params.path,len(params.path)-1);
}

var page = _CMSPage.findByAddress(params.path);

if(len(page.id()) gt 0){
$.event.action("render");
Reply all
Reply to author
Forward
0 new messages