更改模块的uri而不重命名PyroCMS中的类 [英] Change the uri of a module without renaming the class in PyroCMS
本文介绍了更改模块的uri而不重命名PyroCMS中的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
更改模块的uri而不重命名类的最好方法是什么。例如,我希望博客模块显示:
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:
/ 博客 / post-title - > / news / post-title
/blog/post-title -> /news/post-title
routes.php?
routes.php?
推荐答案
我添加到routes.php。
First I added to the routes.php.
$ route ['news /([0-9] +)/ ] +)/([a-zA-Z0-9 _-] +)'] ='blog / $ 1 / $ 2 / $ 3';
$route['news/([0-9]+)/([0-9]+)/([a-zA-Z0-9_-]+)'] = 'blog/$1/$2/$3';
然后确保正确的链接我添加到博客plugin.php。
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);
}
这篇关于更改模块的uri而不重命名PyroCMS中的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文