Search code examples
phpcodeigniterpyrocms

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


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?


Solution

  • 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);
    }