G’day
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:
http://myDomain/index.cfm?event=myEvent.myMethod
I also seem to recall reading one can do a sort of fusebox-esque faux SEO-friendly URL like this sort of thing:
http://myDomain/index.cfm/myEvent/myMethod/
(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:
someRequestObject.setEvent(“myEvent”)
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:
onRequest(template){
include template;
processColdBoxRequest();
}
?
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.
Cheers.