BUGFIX: Searching in news module with pretty urls.
I had a problem when searching with pretty urls in the News module.
I changed the code in line 314 of NewsModule.php:
#$prettyurl = 'news/' . $articleid;
$prettyurl = 'news/'.$articleid."/".$returnid;
GDS
[Fixed] BUG in CMS1.1 NewsModule.php when searching with pretty URLS
[Fixed] BUG in CMS1.1 NewsModule.php when searching with pretty URLS
Last edited by Anonymous on Tue Aug 21, 2007 2:17 pm, edited 1 time in total.
-
- Forum Members
- Posts: 42
- Joined: Wed Nov 10, 2004 10:17 pm
Re: BUG in CMS1.1 NewsModule.php when searching with pretty URLS
I had this problem.
This fixed fixed it perfectly, and I think it should be shipped out with the next version of the News Module as with some site designs it can make the search completely unusable if it contains links to news items as they just don't work when clicked without this fix.
This fixed fixed it perfectly, and I think it should be shipped out with the next version of the News Module as with some site designs it can make the search completely unusable if it contains links to news items as they just don't work when clicked without this fix.
Re: BUG in CMS1.1 NewsModule.php when searching with pretty URLS
Thanks GDS! Works flawlessly with Pretty URL enabled!
Re: [Fixed] BUG in CMS1.1 NewsModule.php when searching with pretty URLS
Well, I am not sure this is the best solution on this problem aftar all, even if this is a simple solution.
When reading the help section of the Search module,
I found a suggestion on how to pass parameters to other modules.
I inserted this on the Search Page:
{search passthru_News_detailpage='newspage' }
And then I added this function in the News module:
# This function is added in modules/News/news.module.php at line 380:
# Called from modules/Search/action.dosearch.php line 150
function SearchResultWithParams( $returnid, $articleid, $attr='', $parms) {
$result = array();
if ($attr == 'article') {
$db =& $this->GetDb();
$q = "SELECT news_title FROM ".cms_db_prefix()."module_news WHERE news_id = ?";
$dbresult = $db->Execute( $q, array( $articleid ) );
if ($dbresult) {
$row = $dbresult->FetchRow();
// 0 position is the prefix displayed in the list results.
$result[0] = $this->GetFriendlyName();
// 1 position is the title
$result[1] = $row['news_title'];
// Page to use for the news-article-details:
if (isset($parms['detailpage'])) {
$pagealias= $parms['detailpage'];
}
else $pagealias="home";
$pageinfo = PageInfoOperations::LoadPageInfoByContentAlias($pagealias);
$content_id = $pageinfo->content_id;
$prettyurl = 'news/'.$articleid."/".$content_id;
// 2 position is the URL to the title.
$result[2] = $this->CreateLink('cntnt01', 'detail', $returnid, '',
array('articleid' => $articleid), '', true, false, '', true, $prettyurl);
}
}
return $result;
}#end
This way, you can actually call any pagealias to read the Newsdetails in.
GDS
When reading the help section of the Search module,
I found a suggestion on how to pass parameters to other modules.
I inserted this on the Search Page:
{search passthru_News_detailpage='newspage' }
And then I added this function in the News module:
# This function is added in modules/News/news.module.php at line 380:
# Called from modules/Search/action.dosearch.php line 150
function SearchResultWithParams( $returnid, $articleid, $attr='', $parms) {
$result = array();
if ($attr == 'article') {
$db =& $this->GetDb();
$q = "SELECT news_title FROM ".cms_db_prefix()."module_news WHERE news_id = ?";
$dbresult = $db->Execute( $q, array( $articleid ) );
if ($dbresult) {
$row = $dbresult->FetchRow();
// 0 position is the prefix displayed in the list results.
$result[0] = $this->GetFriendlyName();
// 1 position is the title
$result[1] = $row['news_title'];
// Page to use for the news-article-details:
if (isset($parms['detailpage'])) {
$pagealias= $parms['detailpage'];
}
else $pagealias="home";
$pageinfo = PageInfoOperations::LoadPageInfoByContentAlias($pagealias);
$content_id = $pageinfo->content_id;
$prettyurl = 'news/'.$articleid."/".$content_id;
// 2 position is the URL to the title.
$result[2] = $this->CreateLink('cntnt01', 'detail', $returnid, '',
array('articleid' => $articleid), '', true, false, '', true, $prettyurl);
}
}
return $result;
}#end
This way, you can actually call any pagealias to read the Newsdetails in.
GDS