SES question

I'd like the ability to have top-level links such as:

www.mysite.com/dogs
www.mysite.com/cats
www.mysite.com/turtles

and have them resolve to: handler.action (e.g. "general.dog",
"general.cat" or even better, the onMissingAction function in that
handler...)

while also having the ability to keep using the traditional:

www.mysite.com/catalog/product

so that it would resolve to "catalog.product"

I just cannot figure out a way to do the former in Coldbox while
preserving the later? I suppose that I can put everything in a
rewrite map file (e.g. point www.mysite.com/dogs to "general.dogs")
but then I wonder if I am dong that, am I better dumping CB version of
SES URLs altogether and do everything via a server re-write?

So I guess I have 2 questions here: first, how *do* I create these
URLs in CB, and second - regardless of #1 - what do people believe the
best practice is here - using the server re-write, CB routing or a
hybrid?

Thanks,
Andy

Why cant you create the first Uris? They are just static Uris that map somewhere. I use them all the time.

Luis Majano
President
Ortus Solutions, Corp
Toll free phone/fax: 1-888-557-8057
Mobile: 909-248-3408

www.coldbox.org

I have a handler that simply displays landing pages. In my routes file, I grab the metadata for that handler and dynamically create routes based upon the method names (and an attribute like addPrettyRoute=“true”).

Jason Durham

If I have this URL: www.mysite.com/dogs, CB will route to dogs.index
by default. I am looking for it to route to something like:
'animals.dogs' while still having www.mysite.com/catalog/food resolve

I'm sure it's easy, but pouring over the docs, I could not see how to
do this specific type of routing solely within CB (aside from removing
the 'index,cfm' in mod_rewrite or IIS) unless I wanted ALL of my URLs
to be top level and default to a single handler...

I know how to do this in mod_rewrite... and I could create a mapfile
with 100 of these in there if I wanted to... I was just wondering how
to do it within CB?

I'm sorry to be so obtuse on this one! :slight_smile:

You can set them up in your routes file like so:

addRoute(pattern=‘dogs’,handler=‘general’,action=‘dogs’);

Or, you could add a PathInfoProvider(Event) method to your routes.cfm file and return a route that fools the ColdBox SES. Here is an example (I just typed it in this chat. Check the regex :slight_smile:

// one route to rule them all
addRoute(pattern=‘foobarfakething/:action’,handler=’

// This method provides the SES interceptor with the CGI.PATH_INFO (if it exists).
// This method allows you to modify the CGI.PATH_INFO used by the SES interceptor before it has
// access to the value.
function PathInfoProvider(Event) {
if (reFindNoCase(’^/(dogs|cats|birds|flowers)/",CGI.PATH_INFO) > 0)
{
return 'foobarfakething/#cgi.path_info#;
}
return CGI.PATH_INFO;
}

Aaron Greenlee
http://aarongreenlee.com/

Search for “PathInfoProvider” on this page for more info: http://wiki.coldbox.org/wiki/WhatsNew:3.0.0.cfm

Aaron that is very useful to know, I must admit this must have not long been added. I missed or haven’t read the docs since it was added, but this is a great little addition.

But I have one question, it is not very clear in which part of the application flow it is applied. In other words it would be nice to know what other parts of the ColdBox framework is already available or what is not available to be used to help with the UDF.

Regards,

Andrew Scott

http://www.andyscott.id.au/

If the UDF exists within the routes.cfm file it is called by the SES interceptor to obtain the CGI.PATH_INFO value. The SES Interceptor routes requests during the preProcess() interception point. The UDF is provided the Event object via arguments. Otherwise, the UDF can access anything that is available during the preProcess() event such as plugins.

Aaron