欢迎访问 舍力博客(www.shuyong.net)
CREATE TABLE IF NOT EXISTS `ecs_content_key` ( `key_id` smallint(5) NOT NULL AUTO_INCREMENT, `key_name` varchar(255) NOT NULL, `sort_order` tinyint(3) unsigned NOT NULL DEFAULT '50', `replace_num` tinyint(3) unsigned NOT NULL, `key_url` varchar(255) NOT NULL, PRIMARY KEY (`key_id`), KEY `sort_order` (`sort_order`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;建表SQL—GBK版本
CREATE TABLE IF NOT EXISTS `ecs_content_key` ( `key_id` smallint(5) NOT NULL AUTO_INCREMENT, `key_name` varchar(255) NOT NULL, `sort_order` tinyint(3) unsigned NOT NULL DEFAULT '50', `replace_num` tinyint(3) unsigned NOT NULL, `key_url` varchar(255) NOT NULL, PRIMARY KEY (`key_id`), KEY `sort_order` (`sort_order`) ) ENGINE=MyISAM DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;二、上传文件包里面的文件替换原来文件 ecsho内链插件:http://pan.baidu.com/s/1nAxPm;下载密码:b33l
$purview['01_shop_config'] = 'shop_config';在它下边增加一行代码
$purview['01_content_key'] = 'content_key';保存上传
$modules['11_system']['01_shop_config'] = 'shop_config.php?act=list_edit';在它下边增加一行代码
$modules['11_system']['01_content_key'] = 'content_key.php?act=list';
$_LANG['01_shop_config'] = '商店设置';在它下边增加一行代码
$_LANG['01_content_key'] = '关键词设置';
if ($goods['brand_id'] > 0)在它上边增加如下代码片段
/* 关键字替换 By 舍力博客 */ $sql="select * from ". $GLOBALS['ecs']->table('content_key') ; $res_k=$GLOBALS['db']->query($sql); while ($row_k=$GLOBALS['db']->fetchRow($res_k)){if($row_k['replace_num']){$goods['goods_desc']=preg_replace('/(?!<[^>]*)'.$row_k['key_name'].'(?![^<]*>)/i', '<a href="' . $row_k['key_url'] . '" target="_blank" >'.$row_k['key_name']."</a>", $goods['goods_desc'], $row_k['replace_num']);}else{$goods['goods_desc']=preg_replace('/(?!<[^>]*)'.$row_k['key_name'].'(?![^<]*>)/i', '<a href="' . $row_k['key_url'] . '" target="_blank" >'.$row_k['key_name']."</a>", $goods['goods_desc']);}$goods['goods_desc']=preg_replace('/(?!<[^>]*)'.$row_k['key_name'].'(?![^<]*>)/i', '<strong>' . $row_k['key_name'] . '</strong>', $goods['goods_desc'],1 );}5、修改 /article.php,找到(大概在157行左右)
if (empty($row['author']) || $row['author'] == '_SHOPHELP') { $row['author'] = $GLOBALS['_CFG']['shop_name']; }
/* 关键字替换 By 舍力博客 */ $sql="select * from ". $GLOBALS['ecs']->table('content_key') ; $res_k=$GLOBALS['db']->query($sql); while ($row_k=$GLOBALS['db']->fetchRow($res_k)) {if($row_k['replace_num']) {$row['content']=preg_replace('/(?!<[^>]*)'.$row_k['key_name'].'(?![^<]*>)/i', '<a href="' . $row_k['key_url'] . '" target="_blank" >'.$row_k['key_name']."</a>", $row['content'], $row_k['replace_num']); }else{$row['content']=preg_replace('/(?!<[^>]*)'.$row_k['key_name'].'(?![^<]*>)/i', '<a href="' . $row_k['key_url'] . '" target="_blank" >'.$row_k['key_name']."</a>", $row['content']);} $row['content']=preg_replace('/(?!<[^>]*)'.$row_k['key_name'].'(?![^<]*>)/i','<strong>' . $row_k['key_name'] . '</strong>', $row['content'],1 );}完成以上步骤,清理缓存,刷新网页就可以实现了
留言/评论:◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。