I recently had to "morph" the news module into a slightly different beast by renaming its core terminology. I wanted to have a master detail page heirarchy just like the News module but set it up using terminology related to the type of information entered by the client. (which wasn't news!)
To achieve this was quite simple by creating a /module_custom/News/lang/ folder and overriding the language entries (in my case en_US.php). So I had my renamed module appearing in the admin and all was good and clear. Good.
However, the urls being generated [mod_rewrite is being used] still contained the word "news". This wasn't going to cut it. Clearly the news module was not inheriting my lovingly applied name changes deeply enough.
So, to get the job done I had to edit some of the module files directly, which I am loathe to do - but I'm not aware of an easy way to override core code otherwise - so now I can't update the module easily (lose my changes in the process).
My issue was this:
the url being generated still contained the term "news" ie:
site/news/1/2/page-alias.html
To have the module use my new module name I had to update two things: the Registered Routes, which was hard coded with the News module name, and the generated pretty urls, also hardcoded. I updated the code to use the overriden name instead that is in the language file.
The code changes:
disclaimer - php is not my language! Still learning.
File News.Module.php
function SetParameters() around line 68
Code: Select all
/** REMOVED **
$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/(?P<junk>.*?)\/d,(?P<detailtemplate>.*?)$/');
$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/(?P<junk>.*?)$/');
$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)$/');
$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)$/');
*/
/**ADDED **/
$modname=strtolower($this->Lang('news')); //the Name of the module, supplied by cms user
/* Create a regex fragment from the name, of the form [nN]ame */
$routename='['.strtolower(substr($modname,0,1)).strtoupper(substr($modname,0,1)).']'.substr($modname,1);
$this->RegisterRoute('/'.$routename.'\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/(?P<junk>.*?)\/d,(?P<detailtemplate>.*?)$/');
$this->RegisterRoute('/'.$routename.'\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/(?P<junk>.*?)$/');
$this->RegisterRoute('/'.$routename.'\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)$/');
$this->RegisterRoute('/'.$routename.'\/(?P<articleid>[0-9]+)$/');
File News.Module.php
function SearchResult() around line 340
Code: Select all
/** REMOVED **
$prettyurl = 'news/' . $articleid.'/'.$returnid."/$aliased_title";
*/
/** ADDED ** /
$modname=strtolower($this->Lang('news'));
$prettyurl = $modname.'/' . $articleid.'/'.$returnid."/$aliased_title";
but finally we need to edit
File: action.default.php
about line 346
Code: Select all
/**REMOVED**
$prettyurl = 'news/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid)."/$aliased_title";
*/
/**ADDED**/
$modname=strtolower($this->Lang('news'));
$prettyurl = $modname.'/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid)."/$aliased_title";
This kind of basic flexibility could *maybe* added to this (or even other) module? In the SVN (hint hint!)

Adrian
[ADDENDUM:]
I have discovered a similar modification in the Tips and Tricks part of the forum. My mod could be a core change though as it would work out-of-the-box with the need to only edit the lang file(s).
http://forum.cmsmadesimple.org/index.php/topic,24968.0.html
My way of changing news pretty url's