加载中 ...
首页 > CMS教程 > dedecms > 正文

织梦dedecms模板中显示最近浏览文章列表的方法示例

2019-09-23 11:42:43 来源:

我们在制作织梦商城模板的时候经常会仿照shopex或者ecshop模式,在列表dede模板中添加最近浏览文章列表,这样可以提高客户的体验度,下面dedecms模板中心跟大家分享下实现方法:

1.后台出执行如下语句

CREATE TABLE `数据库`.`dede_zj` (  `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,  `mid` INTEGER UNSIGNED NOT NULL,  `ip` VARCHAR(45) NOT NULL,  `aid` INTEGER UNSIGNED NOT NULL,  `logintime` VARCHAR(45) NOT NULL,  PRIMARY KEY (`id`))

2.新建php文件count_zj.php 存放到puls目录下内容如下

<?phprequire_once(dirname(__FILE__)."/../include/common.inc.php");require_once(dirname(__FILE__)."/../member/config.php");global $cfg_ml;$mid=$cfg_ml->M_ID;$joinip = GetIP();//当前时间戳$nowTime = time();if($mid){$row = $dsql->GetOne(" Select * From `dede_zj`  where aid=’$aid’ and mid=’$mid’");if(!$row){$dsql->ExecuteNoneQuery("INSERT INTO dede_zj( `id`, `mid`, `ip`,`aid` ,`logintime`)VALUES (  ”,$mid, ‘$joinip’,$aid,$nowTime) ");}$db->SetQuery(" Select title From dede_archives  join dede_zj on dede_archives.id=dede_zj.aid where dede_zj.mid=’$mid’ order by logintime desc limit 1,5");   $db->Execute();   while($row = $db->GetArray())   { echo "document.write(‘".$row['title']."’);\r\n";  } }if(!$mid){$m = $dsql->GetOne(" Select * From `dede_zj`  where aid=’$aid’ and ip=’$joinip’");if(!$m){$dsql->ExecuteNoneQuery("INSERT INTO dede_zj( `id`, `mid`, `ip`,`aid` ,`logintime`)VALUES (  ”,$mid, ‘$joinip’,$aid,$nowTime) ");}$db->SetQuery(" Select title From dede_archives  join dede_zj on dede_archives.id=dede_zj.aid where dede_zj.ip=’$joinip’ order by logintime desc limit 1,5");   $db->Execute();   while($row = $db->GetArray())   { echo "document.write(‘".$row['title']."’);\r\n";  } }exit();?>

3.在文章模板处添加如下语句

  

在引用处直接添加排版本人不在行,功能上是可以实现的,望各位自己酌情处理

补充一点,关于最近浏览链接的问题

<?phprequire_once(dirname(__FILE__)."/../include/common.inc.php");require_once(dirname(__FILE__)."/../member/config.php");global $cfg_ml;$mid=$cfg_ml->M_ID;$joinip = GetIP();//当前时间戳$nowTime = time();if($mid){$row = $dsql->GetOne(" Select * From `dede_zj`  where aid=’$aid’ and mid=’$mid’");if(!$row){$dsql->ExecuteNoneQuery("INSERT INTO dede_zj( `id`, `mid`, `ip`,`aid` ,`logintime`)VALUES (  ”,$mid, ‘$joinip’,$aid,$nowTime) ");}$db->SetQuery(" Select title,dede_archives.id From dede_archives  join dede_zj on dede_archives.id=dede_zj.aid where dede_zj.mid=’$mid’ order by logintime desc limit 1,5");   $db->Execute();   while($row = $db->GetArray())   { echo "document.write(\"\");"; echo "document.write(‘".$row['title']."’);"; echo "document.write(\"\");\r\n";  } }if(!$mid){$m = $dsql->GetOne(" Select * From `dede_zjw`  where aid=’$aid’ and ip=’$joinip’");if(!$m){$dsql->ExecuteNoneQuery("INSERT INTO dede_zjw( `id`, `mid`, `ip`,`aid` ,`logintime`)VALUES (  ”,$mid, ‘$joinip’,$aid,$nowTime) ");}$db->SetQuery(" Select title,dede_archives.id From dede_archives  join dede_zj on dede_archives.id=dede_zj.aid where dede_zjw.ip=’$joinip’ order by logintime desc limit 1,5");   $db->Execute();   while($row = $db->GetArray())   { echo "document.write(\"\");"; echo "document.write(‘".$row['title']."’);"; echo "document.write(\"\");\r\n"; } }exit();?>

覆盖上面的php文件

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

“广域创业网”的新闻页面文章、图片、音频、视频等稿件均为自媒体人、第三方机构发布或转载。如稿件涉及版权等问题,请与

我们联系删除或处理,客服邮箱,稿件内容仅为传递更多信息之目的,不代表本网观点,亦不代表本网站赞同

其观点或证实其内容的真实性。