Welcome Guest, Not a member yet? Register   Sign In
Bug in routes with path in controller
#11
Big Grin 

Thanks very much for your help everyone  Big Grin

This is how my routes are coming along...

Code:
$routes->get('about', 'Main::about', ['namespace' => 'App\Controllers\Front']);
$routes->get('contact-us', 'Main::contactUs', ['namespace' => 'App\Controllers\Front']);
$routes->get('products/(children|men|women)', 'Main::getProducts/$1', ['namespace' => 'App\Controllers\Front']);

I wanted to "group by namespace" but I don't think I can. If not, I will look to having a var for the namespace array.
Reply
#12

You can use the namespace in a group route but all the routes under it should belong to that namespace.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#13

(05-14-2021, 01:35 AM)InsiteFX Wrote: You can use the namespace in a group route but all the routes under it should belong to that namespace.

Hi InsiteFX,

Thanks very much for your help.  Big Grin

If I'm interpreting the group options correctly it looks like I can specify a group "namespace" but not a group "controller" under a group namespace.

So what I have at present is

Code:
$frontNameSpace = ['namespace' => 'App\Controllers\Front'];

$routes->get('/', 'Main::index', $frontNameSpace);
$routes->get('about', 'Main::about', $frontNameSpace);
$routes->get('products/(children|men|women)', 'Main::getProducts/$1', $frontNameSpace);
$routes->get('bag', 'Main::bag', $frontNameSpace);
$routes->get('checkout', 'Main::checkout/card', $frontNameSpace);

Do you think there's a better way to group these routes ?
Reply
#14

(This post was last modified: 05-14-2021, 11:30 AM by InsiteFX.)

You can also declare a controller in the group.

Mistake its the group name for like admin which would make the url admin/routeName.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB