织梦dedecms模板中怎么显示最近浏览文章列表

前端之家收集整理的这篇文章主要介绍了织梦dedecms模板中怎么显示最近浏览文章列表前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

织梦dedecms模板中怎么显示最近浏览文章列表

织梦dedecms模板中怎么显示最近浏览文章列表

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

推荐学习:织梦cms

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`,$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`,$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 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`,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 href=’view.PHP?aid=".$row['id']."’>\");"; 
echo "document.write(‘".$row['title']."’);"; 
echo "document.write(\"</a>\");\r\n"; 
} 
}
exit();
?>

覆盖上面的PHP文件

以上就是织梦Dedecms模板中怎么显示最近浏览文章列表的详细内容,更多请关注编程之家其它相关文章

猜你在找的Dedecms相关文章