Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing wrong default value #1139

Closed
HieuPT7 opened this issue Aug 5, 2018 · 4 comments
Closed

Routing wrong default value #1139

HieuPT7 opened this issue Aug 5, 2018 · 4 comments

Comments

@HieuPT7
Copy link
Contributor

HieuPT7 commented Aug 5, 2018

Hi.
In https://bcit-ci.github.io/CodeIgniter4/general/routing.html
I use in router

$routes->add('blog/joe', 'Blogs::users/34'); but this show 404 page.
Can you recheck it.
Thanks

@byazrail
Copy link
Contributor

byazrail commented Aug 5, 2018

Duplicate #352

@lonnieezell
Copy link
Member

We've got a number of tests on it. In order to see if it's a bug, I need to know how your controller file is setup. Can you provide code please?

@HieuPT7
Copy link
Contributor Author

HieuPT7 commented Aug 6, 2018

In file controller


<?php namespace Modules\Blog\Controllers\Admin;

use App\Controllers\AdminBaseController;

class BlogController extends AdminBaseController
{
    public function detail($slug = '')
    {
           return 'Ok';
    }
}

In router file.


$routes->group('admin', ['namespace' => 'Modules\Blog\Controllers\Admin'], function($routes) 
{
    $routes->get('blog/detail/abc', 'BlogController::detail/dsdsd');
});

I access to link: /admin/blog/detail/abc this show 404
But if change router

$routes->group('admin', ['namespace' => 'Modules\Blog\Controllers\Admin'], function($routes) 
{
    $routes->get('blog/detail/(:segment)', 'BlogController::detail/$1');
});

then success link

Thanks

@lonnieezell
Copy link
Member

The way you changed it is correct and the way that it's intended to be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants