首頁  >  文章  >  CMS教程  >  織夢dedecms模板中怎麼顯示最近瀏覽文章列表

織夢dedecms模板中怎麼顯示最近瀏覽文章列表

藏色散人
藏色散人原創
2019-12-10 09:41:421996瀏覽

織夢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[&#39;title&#39;]."’);\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[&#39;title&#39;]."’);\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>

在引用處直接加入451aa0c8eca6962e1f946d67911af562cc6b4e24f23d50e4f0ab3ed0bf2aac54排版本人不在行,功能上是可以實現的,望各位自己酌情處理

補充一點,關於最近瀏覽鏈接的問題

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

覆蓋上面的php文件

以上是織夢dedecms模板中怎麼顯示最近瀏覽文章列表的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn