![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
#1
IP: 59.60.149.106
|
|||
|
|||
|
Mod Title: Full Article Rewrite
Last Updated: 19 Jan. 2008 Supported by Mod Developer: Yes This mod upgrades the simplistic article rewrite from phpLD 3.3. After installing this mod your article URLs will turn from http://www.mydirectory.com/articles/article-239.html to http://www.mydirectory.com/articles/...itle-here.html Important: backup all files before modifying them! Open admin/article_edit.php Find if ($action == 'N') { $data['DATE_ADDED'] = gmdate ('Y-m-d H:i:s'); } Replace with if ($action == 'N') { $data['DATE_ADDED'] = gmdate ('Y-m-d H:i:s'); $data['TITLE_REWRITE'] = preg_replace ('`[^\w_-]+`', '-', $data['TITLE']); } Open submit_article.php Find $data['META_KEYWORDS'] = (!empty ($data['META_KEYWORDS']) ? clean_meta_keywords($data['META_KEYWORDS']) : ''); Replace with $data['META_KEYWORDS'] = (!empty ($data['META_KEYWORDS']) ? clean_meta_keywords($data['META_KEYWORDS']) : ''); $data['TITLE_REWRITE'] = preg_replace ('`[^\w_-]+`', '-', $data['TITLE']); Open include/tables.php Find $tables['article'] = array ( 'name' => TABLE_PREFIX.'ARTICLE' , 'fields' => array ( 'ID' => 'I KEY AUTO' , 'TITLE' => 'C(255) NOTNULL' , Replace with $tables['article'] = array ( 'name' => TABLE_PREFIX.'ARTICLE' , 'fields' => array ( 'ID' => 'I KEY AUTO' , 'TITLE' => 'C(255) NOTNULL' , 'TITLE_REWRITE' => 'C(255) NOTNULL' , Find $tables['article_review'] = array ( 'name' => TABLE_PREFIX.'ARTICLE_REVIEW' , 'fields' => array ( 'ID' => 'I KEY AUTO' , 'TITLE' => 'C(255) NOTNULL' , Replace with $tables['article_review'] = array ( 'name' => TABLE_PREFIX.'ARTICLE_REVIEW' , 'fields' => array ( 'ID' => 'I KEY AUTO' , 'TITLE' => 'C(255) NOTNULL' , 'TITLE_REWRITE' => 'C(255) NOTNULL' , Open index.php Find //Article search $search_preferences = array (); $search_preferences['Select_Options'] = array ( '`ID`' , '`TITLE`' , Replace with //Article search $search_preferences = array (); $search_preferences['Select_Options'] = array ( '`ID`' , '`TITLE`' , '`TITLE_REWRITE`' , Open .htaccess Find RewriteRule (.*)articles/article-(.*)\.htm[l]?$ article.php [QSA,NC] Replace with RewriteRule (.*)articles/(.*)\.htm[l]?$ article.php [QSA,NC] Open article.php Find (around line 158) elseif (ENABLE_REWRITE == 1) { preg_match ('#(.*)article(_|-)(\d+)\.htm[l]?$#i', request_uri(), $matches); $id = (!empty ($matches[3]) ? intval ($matches[3]) : 0); } Replace with elseif (ENABLE_REWRITE == 1) { preg_match ('`articles/([\w_-]+)\.htm[l]?$`', request_uri(), $matches); $rdata = $db->GetRow("SELECT `ID` FROM `{$tables['article']['name']}` WHERE `TITLE_REWRITE` = '$matches[1]'"); if (!$rdata) { $tpl->assign('error', "Invalid article title - not found in database"); $id = 0; } else { $id = $rdata['ID']; } } Now you have to edit the template files that reference articles. The general rule is to replace anything that references articles/article-{$article.ID}.html with articles/{$article.TITLE_REWRITE}.html NOTE: $article is just a random name. It could appear as $val, $latest_search[i] etc depending on your template. You have to replace it keeping the same variable name (i.e. $val.TITLE_REWRITE, $latest_search[i].TITLE_REWRITE) For example, for the Professional template (the default that comes with 3.3) you have to make the replacements in templates/Professional/articlelink.tpl templates/Professional/article_search.tpl templates/Professional/rightside.tpl Run these SQL queries from the phpLD admin System->Database page or from phpMyAdmin ALTER TABLE `PLD_ARTICLE` ADD `TITLE_REWRITE` VARCHAR( 255 ) NOT NULL AFTER `TITLE` ALTER TABLE `PLD_ARTICLE_REVIEW` ADD `TITLE_REWRITE` VARCHAR( 255 ) NOT NULL AFTER `TITLE` UPDATE `PLD_ARTICLE` SET `TITLE_REWRITE`=CONCAT('article-', `ID`) UPDATE `PLD_ARTICLE_REVIEW` SET `TITLE_REWRITE`=CONCAT('article-', `ID`) |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Top List of Press Release Sites and Article Directories! | yahoo | 网站链接开发 | 0 | 2007-08-17 11:21 AM |
| SupSite/X-Space 启用Rewrite说明 | car | Discuz/SupeSite/X-Space | 0 | 2007-02-23 11:58 AM |
| Article submission list | topvip | 网站链接开发 | 1 | 2006-03-23 01:00 AM |