Hi Guys,
Yes, no problem...
You have to edit 4 files from the Modules / News folder..
action.default.php
action.details.php
News.module.php
and action.rss.php
action.default.php
Find
Code: Select all
$onerow->titlelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $row['news_title'], $sendtodetail, '', false, false, '', true, $prettyurl);
$onerow->morelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail, '', false, false, '', true, $prettyurl);
and REPLACE it with
Code: Select all
// SEO URL Hack
$titleSEO = preg_replace("/[^\w-]+/", "-", $row['news_title']);
$categorySEO = preg_replace("/[^\w-]+/", "-", $row['news_category_name']);
$onerow->link = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, '', $sendtodetail,'', true, false,'',true, 'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));
$onerow->titlelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $row['news_title'], $sendtodetail,'',false,false,'',true,'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));
$onerow->morelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail,'',false,false,'',true,'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));
// SEO URL HACK
// $onerow->titlelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $row['news_title'], $sendtodetail, '', false, false, '', true, $prettyurl);
// $onerow->morelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail, '', false, false, '', true, $prettyurl);
action.detail.php
Find
Code: Select all
$onerow->title = $row['news_title'];
and REPLACE it with
Code: Select all
$this->news_title = $row['news_title'];
News.module.php
Find
And ADD after the {
Code: Select all
// SEO URL hack
$this->RegisterRoute('/(?P<module>News)\/.*?\/.*\-(?P<articleid>[0-9]+)$/', array('returnid'=>'133'));
$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/d,(?P<detailtemplate>.*?)$/');
$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/d,(?P<detailtemplate>.*?)$/');
$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)$/');
$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)$/');
$this->RegisterRoute('/[nN]ews\/(?P<action>rss)\/(?P<category>.*?)$/', array('showtemplate'=>'false'));
action.rss.php
Find
Code: Select all
while ($dbresult && $row = $dbresult->FetchRow())
{
$onerow = new stdClass();
$sendtodetail = array('articleid'=>$row['news_id']);
$onerow->link = $this->CreateLink($id, 'detail', $returnid, '', $sendtodetail,'',true,false,'',true,'news/'.$row['news_id']);
$onerow->id = $row['news_id'];
$onerow->title = $row['news_title'];
$onerow->content = $row['news_data'];
$onerow->summary = $row['summary'];
$onerow->strippedcontent = strip_tags($onerow->content);
$onerow->strippedsummary = strip_tags($onerow->summary);
$onerow->postdate = $row['news_date'];
$onerow->gmdate = gmdate('r', $db->UnixTimeStamp($row['news_date']));
$onerow->startdate = $row['start_time'];
$onerow->enddate = $row['end_time'];
$onerow->category = $row['news_category_name'];
$entryarray[]= $onerow;
}
and REPLACE it with
Code: Select all
while ($dbresult && $row = $dbresult->FetchRow())
{
$onerow = new stdClass();
$sendtodetail = array('articleid'=>$row['news_id']);
$titleSEO = preg_replace("/[^\w-]+/", "-", $row['news_title']);
$categorySEO = preg_replace("/[^\w-]+/", "-", $row['news_category_name']);
$onerow->link = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, '', $sendtodetail,'', true, false,'',true, 'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));
//$onerow->link = $this->CreateLink($id, 'detail', $returnid, '', $sendtodetail,'',true,false,'',true,'news/'.$row['news_id']);
$onerow->id = $row['news_id'];
$onerow->title = $row['news_title'];
$onerow->content = $row['news_data'];
$onerow->summary = $row['summary'];
//$onerow->strippedcontent = strip_tags($onerow->content);
//$onerow->strippedsummary = strip_tags($onerow->summary);
$onerow->strippedcontent = $row['news_data'];
$onerow->strippedsummary = $row['summary'];
$onerow->postdate = $row['news_date'];
$onerow->gmdate = gmdate('r', $db->UnixTimeStamp($row['news_date']));
$onerow->startdate = $row['start_time'];
$onerow->enddate = $row['end_time'];
$onerow->category = $row['news_category_name'];
$entryarray[]= $onerow;
}
I've played with the spacing and code layout so you will have to look / search the files by hand, don't use an automated tool.
You will need the standard Pretty URL's .htaccess file and Pretty URL's already working for articles etc.
The hack also fixes the RSS feed for the new URLs's.
Both Old style URL's still work so SEO is not affected.
These files are from CMSMS version 1.2.3 "Black Rock" (upgraded from 1.2.2), on Apache and Red Hat with MySQL 5 back end (not that it should make a difference..)
I have not added the hack to take out the article number so URL's look like
http://mysite.com/News/General/my-story-[b]12[/b].shtml, I did look at the code but it didn't work + I ran out of time to fix it.
if you want to see it working, have a look at
http://www.avicraft.co.uk
Remember to make a backup of the files BEFORE you edit them, I normally copy the file to the same folder and append the date so action.default.php becomes action.default.php.210107, then edit the original file...
Let me know if you have a problem..
Regards
Courty
