Change the uri of a module without renaming the class in PyroCMS

空扰寡人 提交于 2019-12-11 03:43:34

问题


What is the best way to change the uri of a module without renaming the class. For example I'd like the blog module to show:

/blog/post-title -> /news/post-title

routes.php?


回答1:


First I added to the routes.php.

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

Then to make sure the correct links I added this to the blog plugin.php.

foreach ($posts as &$post)
{
    $post->url = str_replace('blog/', 'news/', $post->url);
}



回答2:


The best way is to use the routes module.

If you don't want to use it, modify the routes.php in cms/config and not in your module because it won't run under a different path.



来源:https://stackoverflow.com/questions/10899376/change-the-uri-of-a-module-without-renaming-the-class-in-pyrocms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!