【问题标题】:Changing the format of the URL in Nette Application在 Nette 应用程序中更改 URL 的格式
【发布时间】:2022-12-24 11:39:00
【问题描述】:

我是内特的新手。

我将路由器设置为

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

在 common.neon 中,我将映射设置为:

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

该站点设置为模块。

为了到达页面,URL 的格式为

http://192.168.56.30/home.signin/

我想改变它所以格式是

http://192.168.56.30/home/signin/

home.signin 格式也是在 latte 文件中使用 n:href 时的显示方式

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

例如,这是翻译成 home.signout。

有没有办法解决这个问题,使其格式更好?

【问题讨论】:

    标签: nette


    【解决方案1】:

    试试这个代码:

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

    或者您可以使用$router-&gt;withModule('Home') 方法(有关详细信息,请参阅https://doc.nette.org/en/application/routing#toc-modules)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      • 2021-05-20
      • 2016-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多