DedeCMS织梦

织梦DedeCMS模板中显示最近浏览文章列表

阿里云

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

1.后台出执行如下语句

也想出现在这里?联系我们
创客主机
  1.  CREATE TABLE `数据库`.`dede_zj` (
  2.   `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  3.   `mid` INTEGER UNSIGNED NOT NULL,
  4.   `ip` VARCHAR(45) NOT NULL,
  5.   `aid` INTEGER UNSIGNED NOT NULL,
  6.   `logintime` VARCHAR(45) NOT NULL,
  7.   PRIMA

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

  1.     <?php
  2.     require_once(dirname(__FILE__)."/../include/common.inc.php");
  3.     require_once(dirname(__FILE__)."/../member/config.php");
  4.     global $cfg_ml;
  5.     $mid=$cfg_ml->M_ID;
  6.     $joinip = GetIP();
  7.     //当前时间戳
  8.     $nowTime = time();
  9.     if($mid)
  10.     {
  11.     $row = $dsql->GetOne(" Select * From `dede_zj`  where aid=’$aid’ and mid=’$mid’");
  12.     if(!$row){
  13.     $dsql->ExecuteNoneQuery("INSERT INTO dede_zj( `id`, `mid`, `ip`,`aid` ,`logintime`)
  14.     VALUES (  ”,$mid, ‘$joinip’,$aid,$nowTime) ");
  15.     }
  16.     $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");   
  17.     $db->Execute();   
  18.     while($row = $db->GetArray())   
  19.     { 
  20.     echo "document.write(‘".$row['title']."’);\r\n";  
  21.     } 
  22.     }
  23.     if(!$mid){
  24.     $m = $dsql->GetOne(" Select * From `dede_zj`  where aid=’$aid’ and ip=’$joinip’");
  25.     if(!$m){
  26.     $dsql->ExecuteNoneQuery("INSERT INTO dede_zj( `id`, `mid`, `ip`,`aid` ,`logintime`)
  27.     VALUES (  ”,$mid, ‘$joinip’,$aid,$nowTime) ");
  28.     }
  29.     $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");   
  30.     $db->Execute();   
  31.     while($row = $db->GetArray())   
  32.     { 
  33.     echo "document.write(‘".$row['title']."’);\r\n";  
  34.     } 
  35.     }
  36.     exit();
  37.     ?>

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

  1.     <SPAN id="span_zj"> 
  2.     <script src="{dede:field name=’phpurl’/}/count_zj.php?view=yes&aid={dede:field name=’id’/}&mid={dede:field name=’mid’/}" type=’text/javascript’ language="javascript"></script>
  3.     <script type="text/javascript">  
  4.     document.getElementById("zj").innerHTML = document.getElementById("span_zj").innerHTML; 
  5.     document.getElementById("span_zj").innerHTML = ""; 
  6.     </script>
  7.     </SPAN>

在引用处直接添加排版本人不在行,功能上是可以实现的,望各位自己酌情处理,补充一点,关于最近浏览链接的问题

  1.     <?php
  2.     require_once(dirname(__FILE__)."/../include/common.inc.php");
  3.     require_once(dirname(__FILE__)."/../member/config.php");
  4.     global $cfg_ml;
  5.     $mid=$cfg_ml->M_ID;
  6.     $joinip = GetIP();
  7.     //当前时间戳
  8.     $nowTime = time();
  9.     if($mid)
  10.     {
  11.     $row = $dsql->GetOne(" Select * From `dede_zj`  where aid=’$aid’ and mid=’$mid’");
  12.     if(!$row){
  13.     $dsql->ExecuteNoneQuery("INSERT INTO dede_zj( `id`, `mid`, `ip`,`aid` ,`logintime`)
  14.     VALUES (  ”,$mid, ‘$joinip’,$aid,$nowTime) ");
  15.     }
  16.     $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");   
  17.     $db->Execute();   
  18.     while($row = $db->GetArray())   
  19.     { 
  20.     echo "document.write(\"<a href=’view.php?aid=".$row['id']."’>\");"; 
  21.     echo "document.write(‘".$row['title']."’);"; 
  22.     echo "document.write(\"</a>\");\r\n";  
  23.     } 
  24.     }
  25.     if(!$mid){
  26.     $m = $dsql->GetOne(" Select * From `dede_zjw`  where aid=’$aid’ and ip=’$joinip’");
  27.     if(!$m){
  28.     $dsql->ExecuteNoneQuery("INSERT INTO dede_zjw( `id`, `mid`, `ip`,`aid` ,`logintime`)
  29.     VALUES (  ”,$mid, ‘$joinip’,$aid,$nowTime) ");
  30.     }
  31.     $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");   
  32.     $db->Execute();   
  33.     while($row = $db->GetArray())   
  34.     { 
  35.     echo "document.write(\"<a href=’view.php?aid=".$row['id']."’>\");"; 
  36.     echo "document.write(‘".$row['title']."’);"; 
  37.     echo "document.write(\"</a>\");\r\n"; 
  38.     } 
  39.     }
  40.     exit();
  41.     ?>

覆盖上面的 php 文件

织梦 DedeCMS 模板中显示最近浏览文章列表

已有 358 人购买
查看演示升级 VIP立刻购买

收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!