[ColdBox 7] Is there a Global ValuePairTranslation Setting?

In Coldbox 7, is there a way to disable or set the default route ValuePairTranslation to ‘false’ globally? Or do I have to specify it manually in every single route definition? This could get cumbersome in an app with many routes. If there isn’t a global setting, perhaps this would be a handy addition?

Example of how to disable it for a route manually:
route( ":slug" ).valuePairTranslation( false ).to( "pages.show" );

lucee.runtime.exp.ExpressionException: invalid component definition, can’t find component [modules.cbmailservices.ModuleConfig]

when I installed cbmailservice in coldbox rest-hmvc it gives me this error

I don’t think your post has to do with what @DaveL posted about?

@yshaukat I think you meant to start a new thread.

On another note, I figured out a possible workaround for disabling valuePairTranslation in my router by default.

I created a new method in Router.cfc called newRoute() which looks like this:

function newRoute( required string pattern ) {
        return route( arguments.pattern ).valuePairTranslation( false );
}

Then, in the configure() method, instead of calling route() every time, I call newRoute():

newRoute( ":slug" ).to( "pages.show" );
1 Like

Thanks for the suggestion but I loaded cbmailservice in rest-hmvc by replacing the directory from modules to coldbox/system/modules and also set the path

@yshaukat, if you want help with cbmailservices, please create a new thread.

Step by step instructions:

  1. Go Here: ColdBox HMVC - Ortus Solutions Community
  2. Click the Plus icon in the lower right hand corner of your screen
    image

Thanks for sharing this.
I am quite new to Coldbox, having spent most of my time, using FW1, but I’ve been wondering how Coldbox uses routes etc.
This will certainly help.
Thinking outside the box, can be very rewarding. :+1:t2:

I was looking at a route example:

But it doesn’t actually show how the route is constructed from a URL, like:

http://localhost/users/show/export/pdf/name
# translate to
event=users.show, rc.export=pdf, rc.name={empty value}

How would you write this route? Would it be:

route('/users/show').to('users.show');

But where do the extra key/value pairs:

rc.export=pdf, rc.name={empty value}

Get added?

OK. I was just having another look at the docs. Am I right in thinking that you write the URL, in let’s say an anchor like:

<a href="http://localhost/users/show/export/pdf/name">Show Users</a>

And then Coldbox monitors all URLs and then if a pattern is matched, it uses the mapping to hit the correct route?

So, it will just convert any extra key/value pairs that aren’t inside the:

route()

Into the rc scope?

@MrKodama,

Yes, I think you have a good understanding of how the value-pair translation works. If you route matches /users/show/ then anything that looks like a path after it, /export/pdf/name, will be value-pair translated as you mentioned in your post: rc.export=pdf, rc.name={empty value}

1 Like