dedecms如何调用出访客最近浏览过的文章
如题,我想在搜索框架下面显示出用户最近访问的文章标题,带连接的那种。或者最近用户搜索过的关键字,这个怎么做,有大神解答下吗。谢谢!解决问题我追加50分,...
如题,我想在搜索框架下面显示出用户最近访问的文章标题,带连接的那种。或者最近用户搜索过的关键字,这个怎么做,有大神解答下吗。谢谢!解决问题我追加50分,
展开
若以下回答无法解决问题,邀请你更新回答
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`)
)
新建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 `#@__zj` where aid='$aid' and mid='$mid'");
if(!$row){
$dsql->ExecuteNoneQuery("INSERT INTO #@__zj( `id`, `mid`, `ip`,`aid` ,`logintime`)
VALUES ( '',$mid, '$joinip',$aid,$nowTime) ");
}
$db->SetQuery(" Select title,#@__archives.id From #@__archives join #@__zj on #@__archives.id=#@__zj.aid where #@__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 `#@__zjw` where aid='$aid' and ip='$joinip'");
if(!$m){
$dsql->ExecuteNoneQuery("INSERT INTO #@__zjw( `id`, `mid`, `ip`,`aid` ,`logintime`)
VALUES ( '',$mid, '$joinip',$aid,$nowTime) ");
}
$db->SetQuery(" Select title,#@__archives.id From #@__archives join #@__zj on #@__archives.id=#@__zj.aid where #@__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();
?>
在文章模板处添加如下语句
<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>排版本人不在行,功能上是可以实现的
后台出执行如下语句
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`)
)
新建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 `#@__zj` where aid='$aid' and mid='$mid'");
if(!$row){
$dsql->ExecuteNoneQuery("INSERT INTO #@__zj( `id`, `mid`, `ip`,`aid` ,`logintime`)
VALUES ( '',$mid, '$joinip',$aid,$nowTime) ");
}
$db->SetQuery(" Select title,#@__archives.id From #@__archives join #@__zj on #@__archives.id=#@__zj.aid where #@__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 `#@__zjw` where aid='$aid' and ip='$joinip'");
if(!$m){
$dsql->ExecuteNoneQuery("INSERT INTO #@__zjw( `id`, `mid`, `ip`,`aid` ,`logintime`)
VALUES ( '',$mid, '$joinip',$aid,$nowTime) ");
}
$db->SetQuery(" Select title,#@__archives.id From #@__archives join #@__zj on #@__archives.id=#@__zj.aid where #@__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();
?>
在文章模板处添加如下语句
<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>排版本人不在行,功能上是可以实现的
追问
这个方法我找到过,可是没效果,可能是我不会用,能做个示例吗
这句放在哪里呢,
我尝试过放在需要显示最近浏览的位置,没效果
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询