Skip to content

How to group links with optional parameter #58

Open
@vladimir-b-slam

Description

@vladimir-b-slam

For grouping I use the pattern, but the problem is that everything works only when the url is specified with the language, without the language it gives an error.

These links work

  • test.com/eng
  • test.com/eng/page
  • test.com/eng/admin/page

But these links do not work

  • test.com
  • test.com/page
  • test.com/admin/page
$patterns = array(
    ':lang' => 'ua|ru|eng|de'
);
$router->pattern($patterns);

$router->group(':lang?', function($router) {
    $router->get('/', function() {
        return 'Front';
    });

    $router->get('page', function() {
        return 'Front - page';
    });


    $router->group('admin', function($router) {
        $router->get('/', function() {
            return 'Admin';
        });

        $router->get('page', function() {
            return 'Admin - page';
        });
    });
});

How to solve this problem? Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions