VIP福利
主页 > 建站问题 > 织梦技巧 > dedecms织梦模板网站中显示最近浏览文章列表的办法

dedecms织梦模板网站中显示最近浏览文章列表的办法

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



我们在制作织梦商城模板的时候经常会仿照shopex或者ecshop模式,在列表织梦模板中添加最近浏览文章列表,这样可以提高客户的体验度,下面跟大家分享下实现方法:
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   PRIMARY KEY (`id`)
8 )

2.新建php文件count_zj.php 存放到puls目录下内容如下
01 <?php
02 require_once(dirname(__FILE__)."/../include/common.inc.php");
03 require_once(dirname(__FILE__)."/../member/config.php");
04 global $cfg_ml;
05 $mid=$cfg_ml->M_ID;
06 $joinip = GetIP();
07 //当前时间戳
08 $nowTime = time();
09 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']."’);rn";
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']."’);rn";
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>

在引用处直接添加<SPAN id="span_zj"></SPAN>排版本人不在行,功能上是可以实现的,望各位自己酌情处理
补充一点,关于最近浏览链接的问题
查看源码打印代码帮助
查看源码
 
打印代码帮助
01 <?php
02 require_once(dirname(__FILE__)."/../include/common.inc.php");
03 require_once(dirname(__FILE__)."/../member/config.php");
04 global $cfg_ml;
05 $mid=$cfg_ml->M_ID;
06 $joinip = GetIP();
07 //当前时间戳
08 $nowTime = time();
09 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>");rn";
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>");rn";
38 }
39 }
40 exit();
41 ?>

覆盖上面的php文件
 

共有 条评论