Search code examples
nette

Changing the format of the URL in Nette Application


I am new to Nette.

I have the router set up as

$router->addRoute('<presenter>/<action>[/<id>]', 'Home:home:default');

In common.neon I have the mapping set to:

*: App\Modules\*\Presenters\*Presenter

The site is set up as modules.

In order to get to a page the URL is in the format of

http://192.168.56.30/home.signin/

I am wanting to change it so the format is

http://192.168.56.30/home/signin/

The home.signin format is also how it is presented when using the n:href in latte file

<a class="nav-link active" n:href=":Home:Signout:default">Sign Out</a>

this is translating to home.signout for example.

Is there a way to fix this so its in a nicer format?


Solution

  • Try this code:

    $router->addRoute('<module>/<presenter>/<action>[/<id>]', 'Home:home:default');
    

    Or you can use $router->withModule('Home') method (see https://doc.nette.org/en/application/routing#toc-modules for details).