2

在不重命名类的情况下更改模块的 uri 的最佳方法是什么。例如,我希望博客模块显示:

/博客/post-title -> /新闻/post-title

路线.php?

4

2 回答 2

3

首先我添加到routes.php。

$route['news/([0-9]+)/([0-9]+)/([a-zA-Z0-9_-]+)'] = 'blog/$1/$2/$3';

然后为了确保正确的链接,我将它添加到博客 plugin.php。

foreach ($posts as &$post)
{
    $post->url = str_replace('blog/', 'news/', $post->url);
}
于 2012-06-05T17:02:48.353 回答
1

最好的方法是使用路由模块。

如果您不想使用它,请修改routes.phpincms/config而不是在您的模块中,因为它不会在不同的路径下运行。

于 2012-06-05T15:23:51.680 回答