1084

Custom Routing : Include Custom Routes

Comments for “Custom Routing : Include Custom Routes”
 

Posted by Reconix on Friday 14th January 2022 at 09:43 GMT

Is it possible to get custom routing from the modules rather than having it all bunched up in custom_routing.php.

Example: modules\welcome\welcome_routing.php

So we can do something like this in the custom_routing.php


if (file_exists(APPPATH.'modules/'.$moduleName.'/'.$moduleName.'_routing.php') )
{
 include(APPPATH.'modules/'.$moduleName.'/'.$moduleName.'_routing.php');
}



Could make that a little bit better but you get the idea, I done a simple include to test and obviously the include gets included but not the defined $routes.

Probably missing something silly but maybe it's the way routes are handled ?

Reconix

User Level: Guest

Date Joined: 14/01/2022

Posted by djnordeen on Saturday 15th January 2022 at 15:04 GMT

Hello,
I would think that you would have to find a way to add to the $routes variable in the config/custom_routes file. $routes is then set in the CUSTOM_ROUTES variable passed to the get_segments file.
This CUSTOM_ROUTES is loaded at runtime. Not sure if what you want is possible.
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

Posted by Greenkey on Monday 24th January 2022 at 01:52 GMT

One day this may just happen.
'thankyou' => 'paypal/thankyou'
'common-questions' => 'webpages/common_questions'
custom_routing is happy.
Founding Member

Greenkey

User Level: Founding Member

Date Joined: 16/11/2018

Posted by Davcon on Saturday 29th January 2022 at 18:26 GMT

The answer is 'no'.

At least, I think it's no.

The framework starts by going through 'core', 'boostrap', then 'Trongate.php'. The main purpose of all of that is to figure out which module to load - based on the URL and type of HTTP request.

By the time the module has been invoked, you've made it past the point of figuring out what to load.

I think there IS a hypothetical of having the Trongate class reference the 'current module' but it's all ridiculously confusing. I just can't do it. Even if I could figure it out, we'd be lost in web of IF statements. It's a mug's game.

I apologise if it's not the answer you were hoping for.

Macho love.
Founding Member

Davcon

User Level: Founding Member

Date Joined: 3/11/2018

Posted by DaFa on Wednesday 9th February 2022 at 04:10 GMT

spot on DC, the answer is no.
Founding Member

DaFa

User Level: Founding Member

Date Joined: 30/11/2018

Posted by Reconix on Friday 15th April 2022 at 23:51 GMT

Sorry for the late reply. Yeah, a simple yes or no whith a why is great thank you, thought maybe I was just missing a trick or two.

At the same time it's doable though, when I next have some free time I wouldn't mind having a little bash at this.

[ Can consider this closed or resolved now. ]

This comment was edited by Reconix on Friday 15th April 2022 at 23:54 GMT

Reconix

User Level: Guest

Date Joined: 14/01/2022

Posted by djnordeen on Saturday 16th April 2022 at 00:18 GMT

To close this could you please select the best answer and click the star in that thread.
Thanks,
Dan
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

×