Using myEvent.cfm instead of index.cfm?event=myEvent

Sorry, I’ve been googling this for about an hour, and have drawn a blank.

The default approach to calling a Coldbox event seems to be via URL parameters, eg:


I also seem to recall reading one can do a sort of fusebox-esque faux SEO-friendly URL like this sort of thing:


(or something like that, the precise syntax is neither here nor there, because that’s just grim, and I’ll not do it)

Let’s say I want to have an actual CFM file, thus:


And I want that to set the event to run as if the URL was index.cfm?event=myEvent.

I had a hunt around for a way to call a method on something to say “this is the entry point for this request”, eg something like:


but have drawn a blank.

Also, looking at how Coldbox seems to be called in, it’s all done in onRequestStart(), which runs before the requested file (ie: myEvent.cfm), so I’m possibly on a hiding to nothing here.

I’m not actually married to this approach, but I figured my app is going to be so small it’s only going to have half a dozen requestable files, so I might as well actually have the files there. However as it seems to go against how CB works, I’m probably backing away from this approach and will just use the URL params approach, but I don’t like having unanswered questions floating around in my head, so I figured I’d seek out an answer.

So if I wanted - for whatever reason - have a file myEvent.cfm, what code would I put in it to set the event (and method, I suppose) to run for the request? It would seem that if I wanted the code in myEvent.cfm to be used, then I’d need to remove the call to Coldbox’s onRequestStart() out of Application.cfc’s onRequestStart(), and perhaps do this sort of thing:

include template;


Basically it’s how do I explicitly say - with code - “do this event / method” for a given request, rather than have Coldbox assume it from URL params or faked SEO paths in the URL.


What you’ve proposed (onRequest()) might work, but I don’t understand why you’d want to do that. ColdBox (and virtually every other CFML framework) is a front controller framework. Circumventing that to use old school templates as the controller just doesn’t make sense to me.

What issue(s) are you trying to solve by circumventing the front controller?

The answer to that question might lead to other options / suggestions that would be more appropriate.

I might be wrong here, but Adam I think your over complicating this.

index.cfm is the page being called.


So if you want to do it the way you want to do it, then you would rename index.cfm to be that of what you want. Now when you have done that, you need to then tell the SES Search Engine that this is the case.

In your Routes.cfm you will see index.cfm, so then change the index.cfm to the name of the file. If your using rewrite rules, then you will need to make the changes to that as well.

H Matt
Yeah, like I said, the minutiae of how I came to be asking the question is neither here nor there; that was just a framing for the situation, and you’re not really getting the bit which I indicated —> this is the actual question <—

Here’s the actual question:
Basically it’s how do I explicitly say - with code - “do this event / method” for a given request, rather than have Coldbox assume it from URL params or faked SEO paths in the URL.

That said, let’s go back to what you said. Most websites - I think you’ll find - don’t rely on URL params to dig out what page the person is requesting. If we’re talking about what’s “old school”, then running everything out of index.cfm with params to identify the page the person actually wants is “old school”. These days the address in the URL is generally just a path to the document. Behind the scenes there will quite possibly be rewrites going on to translate /section/subsection/page/ to “variablised” parameters, but the specifics of the underlying framework generally aren’t exposed to to the site user.

Having stuff like index.cfm?event=event.method exposed to the site user is like something from ten years ago.

My “problem” is that I’m used to seeing “real” URLs, so I sat down thinking “well I can’t be arsed getting mod_rewrite all configured for this site, and it’s only wee so I’ll just create the actual files…”. Before I realised I had no idea how to tell the physical file what event/method it corresponded to. And I quickly reversed my position and thought “actually I don’t care if the URLs look a bit amateurish on this site, so URL params are fine”.

I figured if I wanted to emulating rewrites in a cheap and nasty way I could just sue onMissingTemplate() to infer it from the file path, but then I’d still need some mechanism to tell Coldbox what to do.

Bottom line, though, is the whole thing just piqued my interest, so I thought I’d ask the question. It’s now very much decoupled from how I’ve decided to approach things. Make sense?


OK, seems my use of bold to indicate what I was actually asking didn’t pan out so well. Let’s try again.

Here’s the question I am asking:

Basically it’s how do I explicitly say - with code - “do this event / method” for a given request, rather than have Coldbox assume it from URL params or faked SEO paths in the URL.

That’s the sum total of what I want to know.


But cheers for pointing me in the direction of routes.cfm (odd that it’s a CFM rather than a CFC?) though. I wasn’t aware of that. It looks quite cool. Am reading the docs on it now.

If you use “proper” ses - i.e (without the need for the index.cfm), then I’m not entirely sure how you’d do that with a traditional URL in any different way.

For example, how is any different than (which is how you’d do it via coldbox). The only real difference is that your code would be in handlers/login.cfc instead of /login.cfm - but the principals are exactly the same…

index.cfm doesn’t actually do anything in coldbox - it’s empty, but it has to be there so the web server knows you’re “requesting” a coldfusion page, and therefore passes the request through the jrun proxy. It doesn’t actually do anything…

Ok then I am confused…

ColdBox runs handlers/actions not event/method, and you are right it is coded behind the scenes. There are a multitude of ways you can setup the default route or parent handler. This can be done in the config.cfc or you could do this in the route to add the required handler and action to that route.

So a url could look like this


If you don’t change the routes, then this will default too the component myHandler with the method myAction.

If you go by the routes in say ModuleConfig.cfc then you could do something like this.


Which clearly says the handler or event as your calling it, will begin with entries/page and then a variable will be defined for the page, and the handler will be entries.

I think that is closer to what you might be asking.

Other than that Adam, I still don’t know what it is your asking.

Hi Tom

Skip over the next three paras if you want to be spared my editorialising :wink:

The idea of “SES” has been obsolete for about ten years. Search engines will quite happily index URLs with parameters in the for about as long as Google has been around. SEO-friendliness is a different kettle of fish but derived from the same notion, but is more about having clear hierarchical/organisation context in the path to the document as this supposedly helps categorise the document in search analysis (TBH, I think the whole practice of SEO is a questionable one, I think). I suppose I should have said “human-friendly”. Or just “without the params on it”.

A URL is supposed to point to a document. doesn’t point to a document, it points to a directory, and in these cases the default document is delivered. However if I was wanting to point someone specifically to a login “document”, then would be more “correct” than pointing them to the default document of the login directory (which would suggest there’s a collection of documents about “login” within it, and the default document should help to find which one I actually want). This is kinda splitting hairs, but if we’re deciding which is “more correct” out of having a URL ending in a directory or a URL ending in a file, and the intent is that a specific file is wanted, then the login.cfm version is “more correct” than the login/ version.

Anyway, whatever! It’s a very minor tangential point that it’s completely legit to have a URL ending in a file name, and - indeed - more correct in most cases than not having a filename. And the merits or otherwise of various URL schemes are pretty much irrelevant to my question.

You get to the grist of the matter though with this statement:
The only real difference is that your code would be in handlers/login.cfc instead of /login.cfm - but the principals are exactly the same…

Yep… that’s where I got to. In a method in an event handler CFC I have some “stuff” there to run methods against, and it’s all nicely wrapped up for me and works well.

But there’s some code SOMEWHERE in Coldbox that says “right… I’m gonna run the event handler for this request…”, and it looks up some data structure, finds out which CFC and method to run, and then runs them. That data gets into that data structure somehow… you know, Coldbox’s inner workings sees the params in the URL or the defaults in the config CFC and takes that info and puts it into the data structure which is then subsequently used by the “which event handler to run” code. What I want to know… all I want to know… is how to set that data. Somewhere, in some object, there’s a method along the lines of this:

setRequestEventHandlerAndMethod(handler=something, method=somethingElse);

I just want to know what that is. Just as a matter of interest.

I no longer want to know what that is because I specifically want to use it, I just came to be wondering what it is, because it happened to fall into my brain to want to know.

I thought it was a really really simple question, but it seems not, and I am beginning to regret asking it.

Cheers for your reply though :slight_smile:

Routes.cfm is the solution to your problem.

Your pseudo code with setRequestEventHandlerAndMethod() is pretty close to what already exists in routes.cfm. Look for the following bit of code…


If you’re determined to use file extensions in your URL, use something that doesn’t currently exist in your environment and have mod_rewrite transform it.

Jason: thank-you.

After Andrew’s tip-off and your further mention, I’m def gonna have a look at routes.cfm and how it all works. I am building an ever-increasing list of “stuff to look at”. When this is all gonna happen, I dunno… for the time being I’m just investigating the bare minimum of stuff I need to move forward.

Ifyou wanted to run a normal template but have ColdBox process it youu can use the missing template handler. Tis routes missing templates to an event of your choice where it is now your responsibility to route.

I have used this approach before to simulate templates and actually this was how codex wiki was built before.

Luis Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
Social: | |

The thing to remember Adam, is that ColdBox is an MVC framework application. And one can sometimes get lost, if you forget that at times with ColdBox.

The URL is an endpoint only, and is seen differently from client as it is to server, clients only care that it is an end point where servers then take the information, to then work out what is needed to be returned.