发布时间:2023-05-27 18:58:56
来源:网络
.
乐观主义者从每一个灾难中看到机遇,而悲观主义都从每一个机遇中看到灾难。无论有多困难,都坚强地抬头挺胸,人生是一场醒悟,不要昨日,不要明天,只要今日。
我们在制作织梦商城模板的时候经常会仿照shopex或者ecshop模式,在列表
织梦模板中添加最近浏览文章列表,这样可以提高客户的体验度,下面跟大家分享下实现方法:
dedecms织梦网站中显示最近浏览文章列表
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']."’);rn";
}
}
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']."’);rn";
}
}
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>");rn";
}
}
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>");rn";
}
}
exit();
?>
|
覆盖上面的php文件
以上就是dedecms织梦模板网站中显示最近浏览文章列表的办法。做人要当提起时提起,当放下时放下。功名富贵放不下,生命就在功名富贵里耗费;悲欢离合放不下,生命就在悲欢离合里挣扎;放不下金钱,放不下名位,放不下人情,生命就在金钱名位人情里打滚;对是非放不下,对得失放不下,对善恶放不下,生命就在是非、善恶、得失里面,不得安宁。更多关于dedecms织梦模板网站中显示最近浏览文章列表的办法请关注haodaima.com其它相关文章!