ColdBox Modules and routing

I am looking at doing something that I am not sure is possible with the new modules, so if anyone has some experience or even some ideas then I would like to discuss this further.

The problem I am having is trying to get my head around calling the module, but from a defined route to begin with.

So if I develop say a community type site and it has a url like

www.domainname.com/somedefinedvar/name/admin

Now Admin is the module in question, and the name could be something like Andrew-scott or maybe andyscott or even andy-scott.

Would the module still be able to be setup in this manner?

Regards,

Andrew Scott

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

You should be able to define a pattern that matches the location to
your module in the host application.

addModuleRoutes(pattern="/somedefinedvar/:name/admin",module="admin");

if somedefinedvar is configurable, you could tie this to a setting and
make your module routes dynamic:

addModuleRoutes(pattern="/" & getSetting("settings")["someDefinedVar"]
& "/:name/admin",module="admin");

hth,

.brett

It does and is what I am doing, the problem is that pattern variable :name
is not available in the module.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of Brett
Sent: Friday, 3 September 2010 1:02 AM
To: ColdBox Platform
Subject: [coldbox:5548] Re: ColdBox Modules and routing

You should be able to define a pattern that matches the location to your
module in the host application.

addModuleRoutes(pattern="/somedefinedvar/:name/admin",module="ad
min");

if somedefinedvar is configurable, you could tie this to a setting and

make

I take it nobody knows?

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: Andrew Scott [mailto:andrews@andyscott.id.au]
Sent: Friday, 3 September 2010 1:00 AM
To: coldbox@googlegroups.com
Subject: RE: [coldbox:5548] Re: ColdBox Modules and routing

It does and is what I am doing, the problem is that pattern variable :name

is

Name is in the request collection so it is available

No it's not Luis, that's why I am posting here

If in my handler I do this.

var rc = event.getCollection();
writweDump(rc); abort;

There is nothing from the original route anywhere to be seen.

Regards,
Andrew Scott
http://www.andyscott.id.au/

Ok try this.

1. Create an entry point to your module in the parent app. Maye like

AddModuleRoute("/mymod","modulename")

This just maps a piece of the URL to your module. Then in your actual module config create the dynamic ses route that you would like to look for.

Have you tried this?

If I try to put the information in the MoudlConfig the handlers will not
run, if I do this in ColdBox.cfc

The handlers will run, but the information before it is not passed over.

addModuleRoutes(pattern="/community/:name/forgebox",module="forgebox");
  addRoute(pattern=":handler/:action?");

As I said if I do as you suggest the handlers are not run at all, I spent
some time going through the code line by line with the debugger. The regex
is created for the addModuleRoute, but when it comes to calling the handler
the rc is not passed over.

I'll continue to do more testing, but I can tell you know if I don't add
what I have above the handler for the Module is never executed.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of Luis Majano
Sent: Friday, 3 September 2010 11:33 AM
To: coldbox@googlegroups.com
Subject: Re: [coldbox:5560] Re: ColdBox Modules and routing

Ok try this.

1. Create an entry point to your module in the parent app. Maye like

AddModuleRoute("/mymod","modulename")

This just maps a piece of the URL to your module. Then in your actual

module

Luis, nothing I try works.

Here is what I want to do

www.domainname.com/community/andyscott/module/2010/09/01

If I try this in Routes.cfc

addModuleRoute('pattern='/module', module='module);

and moduleConfig.cfc

routes = [
  {pattern="/community/:name/module",
handler="manager",action="index"},
  {pattern="/community/:name/module
/:year-numeric?/:month-numeric?/:day?/:blogTitle?",
handler="manager",action="dspPosts"}
];

I get community.index is not a registered event.

However if I do
addModuleRoute('pattern='/community/:name /module', module='module);
routes = [
  {pattern="/ ", handler="manager",action="index"},
  {pattern="/:year-numeric?/:month-numeric?/:day?/:blogTitle?",
handler="manager",action="dspPosts"}
];

Both handlers can be called fine, the only problem is that the pattern for
:name is NEVER passed over to the modules.

This is a show stopper for me now.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of Luis Majano
Sent: Friday, 3 September 2010 11:33 AM
To: coldbox@googlegroups.com
Subject: Re: [coldbox:5560] Re: ColdBox Modules and routing

Ok try this.

1. Create an entry point to your module in the parent app. Maye like

AddModuleRoute("/mymod","modulename")

This just maps a piece of the URL to your module. Then in your actual

module

Andy,

You are correct, the :name var is never passed in(although the docs
never say it will be) and something I'm sure we will look into(would be
a nice behavior), but it certainly doesn't have to be a show stopper.
It's not so difficult to grab that variable out of the URL yourself as
you know the pattern and place it in the request collection.

Curt Gratz
Computer Know How

I am training now but will digest this further. Please stay tuned.

Ok, now I see what you are trying to do.

There is a misconception. first, the addModuleRoute in the parent creates an entry point int the URL

www.domainname.com/community/andyscott/module/2010/09/01

What is the entry point here?
I would suspect: community?

Anyways, here is the current implementation. I create the addModuleRoute(pattern="/community",module=“MyModule”)

Once the /community is detected in the URL, the REMAINING part of the URL is SENT to the module for routing and tries to match those.

So /andyscott/module/2010/09/01 is sent to the route for matching, as the first part “/community” has already matched and removed from the evaluation string.

This should clear up what you need. You need a prefix in the URL for a module entry point, the rest is parsable. I find it weird that you would have the module name in the middle or end of a route.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

How is it weird?

If you are expecting the :name as I am doing to be community based, how would you then apply your module across many users?

The problem I have with your solution, is will this work across multiple modules?

Regards,

Andrew Scott

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

How the url is empty when it hits the module.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of Curt Gratz
Sent: Friday, 3 September 2010 9:51 PM
To: coldbox@googlegroups.com
Subject: RE: [coldbox:5564] Re: ColdBox Modules and routing

Andy,

You are correct, the :name var is never passed in(although the docs never
say it will be) and something I'm sure we will look into(would be a nice
behavior), but it certainly doesn't have to be a show stopper.
It's not so difficult to grab that variable out of the URL yourself as you

know

The problem with this approach is that the normal handlers will not run, I made this very clear earlier that this was the problem.

And it will not do this for multiple modules either, which is a pain in the butt here. Here is a snapshot of what I am trying to achieve with the modules, as this is already working without them.

The site is a comunnity based site, in which the following urls will give the site details

www.domainname.com or www.domainname.com/community

From there a person can signup and create a page on this site, which then becomes

www.domainname.com/community/andyscott/

From here I can then add pages to their community space, and in this example it could be say a blog for instance

www.domainname.com/community/andyscott/blog

All the suggestions that have been put forward, then break the first 2 URL calls and will also stop any other modules from being placed onto the users space. Now I know that I can switch this to the following URL, but this is not the requirements of this site and is not acceptable.

www.domainname.com/blog/andyscott

So I hope this clears the problem up some more, and I have tried moving things around to get multiple modules working with the system handlers and nothing will work. My initial way of doing it sort of works, but it falls over because the routes that are defined are not persisted across to the module. Once that is solved then I will be back up and running again converting my core code into modules and system.

Regards,

Andrew Scott

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