URL rewrite for XOOPS news module
by Gabi SolomonFor this example we will considet that the nes module name is PS2. You can adapt this to whatever you want to.
First lets start by adding the rewrite Rules :
# Welcome to Windows IIS URL Rewriting! Below are the rules[ISAPI_Rewrite]# test rewrite StateRewriteRule /testrewrite.html / [I,L] # PS2 news Topic Rewrite : /ps2-c191-test-Article.html RewriteRule ^.*/ps2-c([0-9]*)-[^/]+.html /modules/news/index.php?storytopic=$1 [I,L] # PS2 news Rewrite : /ps2-191-test-Article.html RewriteRule ^.*/ps2-([0-9]*)-[^/]+.html /modules/news/article.php?storyid=$1 [I,L]
# Welcome to Linux Url-Rewrite # PS2 news Topic Rewrite : /ps2-c191-test-Article.html RewriteRule ^.*/ps2-c([0-9]*)-[^/]+.html /modules/news/index.php?storytopic=$1 [L] # PS2 news Rewrite : /ps2-191-test-Article.html RewriteRule ^.*/ps2-([0-9]*)-[^/]+.html /modules/news/article.php?storyid=$1 [L]
Next we need to add a new function to the module so we open /modules/news/include/functions.php and add a new function to the end of the file right before the php end tag ?>
/** * Create an url safe text*
* @package News
* @author Gabriel Solomon ( solomongaby at yahoo.com )
* @copyright (c) GSDesign www.gsdesign.ro
*/
function make_url($text)
{ $urlName = strtolower($text);
$trans = array(
" " => "-",
"/" => "",
"'" => "",
'"' => "",
);
$trans[trim( " / " )] = "";
$urlName= strtr($urlName, $trans);
return $urlName;
}
After this we need to register our new function as a smarty modifier. So we open /class/template.php and after
$this->Smarty();
we add
$this->register_modifier("make_url", "make_url");
Now we start to modify files :
/modules/news/class/class.newsstory.php
The modifications are saved in the file class.newsstory.php available in this file :
class.newsstory.php Modifications
/module/news/templates/news_article.html
The modifications are saved in the file news_article.html available in this File
news_article.htm Modifications
Hope you will find this usefull.
We are working on an installer and as soon as we have it you will find it here.
Awaiting you’re comments and reviews.
Related Posts
-
Gabi Solomon
-
hi
-
Gabi Solomon
-
Márcio Pereira
-
Gabi Solomon
-
FaYsSaL
-
Gabi Solomon
-
mEsoL

