dedecms织梦网站中显示最近浏览文章列表

夏夜,天上缀满了闪闪发光的星星,像细碎的流沙铺成的银河斜躺在青色的天宇上。大地已经沉睡了。我任了性,纵容思念开成一片海,定格成回忆里抹不去的风景。太阳把大海映红了,好像得大海披上了一层红纱。

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

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目录下内容如下

<?php
require_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.在文章模板处添加如下语句

<SPAN id="span_zj">
<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>
<script type="text/javascript"> 
document.getElementById("zj").innerHTML = document.getElementById("span_zj").innerHTML;
document.getElementById("span_zj").innerHTML = "";
</script>
</SPAN>

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

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

<?php
require_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(\&;<a rel="nofollow noopener noreferrer" href=’view.php?aid=".$row['id']."’>\&;);";
echo "document.write(‘".$row['title']."’);";
echo "document.write(\&;</a>\&;);\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(\&;<a rel="nofollow noopener noreferrer" href=’view.php?aid=".$row['id']."’>\&;);";
echo "document.write(‘".$row['title']."’);";
echo "document.write(\&;</a>\&;);\r\n";
}
}
exit();
?>

覆盖上面的php文件

到此这篇关于dedecms织梦网站中显示最近浏览文章列表就介绍到这了。人生只有走出来的美丽,没有等出来的辉煌。更多相关dedecms织梦网站中显示最近浏览文章列表内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

您可能有感兴趣的文章
织梦dede文章列表调用标签的用法和规则

dedecms v5.7文章列表“隔行换色”效果

织梦会员空间文章列表无法分页怎么办

织梦autoindex标签给DEDECMS文章列表添加自动编号

织梦dede首页文章列表arclist按照'weight'权重由小到大