65798

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:

/<strong>blog</strong>/post-title -> /<strong>news</strong>/post-title

routes.php?

Answer1:

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

Answer2:

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.

Recommend

  • Does pImpl fundamentally solve C++ DLL issue?
  • How to activate JS data-filter when page loads?
  • why route of backbone needs the default route
  • How should I start to implement RESTful web service?
  • Manage different base layouts in Angular2
  • React Router and Arbitrary Query Params: Page Refreshes Unintentionally on Load?
  • How to wait for all async tasks to finish in Node.js?
  • PWA with multiple pages
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • Sesame : how to remove the inference during queries?
  • Laravel 4 routing not working due to .htaccess file?
  • HttpURLConnection.getOutputStream() takes 20 seconds. Why?
  • Iron Router: How do I send data to the layout?
  • Can I have a variable number of URI parameters or key-value pairs in Laravel 4?
  • CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
  • Android Google Maps API v2 start navigation
  • System.InvalidCastException: Specified cast is not valid
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Is there a perl module to validate passwords stored in “{crypt}hashedpassword” “{ssha}hashedpassword
  • How to define and use opencv mat of user type
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • Meteor helpers not available in Angular template
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Display issues when we change from one jquery mobile page to another in firefox
  • Cassandra Data Model
  • Upload files with Ajax and Jquery
  • To display the title for the current loaction in map in iphone
  • Do I've to free mysql result after storing it?
  • SetUp method failed while running tests from teamcity
  • A cron job substitute?
  • json Serialization in asp
  • trying to dynamically update Highchart column chart but series undefined
  • Free memory of cv::Mat loaded using FileStorage API
  • using HTMLImports.whenReady not working in chrome
  • Getting Messege Twice Using IMvxMessenger
  • Memory offsets in inline assembly
  • Turn off referential integrity in Derby? is it possible?
  • Python/Django TangoWithDjango Models and Databases
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize