帝国CMS实现用户当前访问的历史记录(产品浏览记录)
帝国如何实现调用用户的访问记录,今天跟着小编来看一看吧,效果图如下一:在e/class/userfun.php中加://--------------------开始------------------functionuser_SetCook($name,$id,$time=0,$num=10){//cookie名称ID时间……
帝国如何实现调用用户的访问记录,今天跟着小编来看一看吧,效果图如下
一:在e/class/userfun.php中加:
//--------------------开始------------------functionuser_SetCook($name,$id,$time=0,$num=10){//cookie名称ID时间戳数量if(!$id){printerror2('不存在的记录',$_SERVER['HTTP_REFERER']);}$prodq=$id.'|';$projilu=getcvar($name);if($projilu){$prozuhe=$prodq.$projilu;//把新浏览的放在第一$pro_arr=explode('|',$prozuhe);$new_arr=array_merge(array_unique($pro_arr));//去除重复,重新索引下标foreach($new_arras$key=>$val){if(($key<$num)&&$val){$pro.=$val.'|';}}}else{$pro=$prodq;}esetcookie($name,$pro,$time);//esetcookie($name,'',0);//print_r($_COOKIE);}functionuser_GetCook($name,$tbname,$num=10){//名称数据表数量global$empire,$dbtbpre;if(preg_match("/^[0-9|]+$/",getcvar($name))){$jilu_all=substr(getcvar($name),0,-1);//1|2|3$jilu_arr=explode('|',$jilu_all);foreach($jilu_arras$k=>$v){$jilu_idin.=(int)$v.',';}$jilu_idin=substr($jilu_idin,0,-1);//1,2,3$sql=$empire->query("selectid,title,titlepic,titleurlfrom{$dbtbpre}ecms_{$tbname}whereidin({$jilu_idin})orderbyfind_in_set(id,'{$jilu_idin}')limit{$num}");//按idin里面的排序while($jilu_r=$empire->fetch($sql)){$titleurl=sys_ReturnBqTitleLink($jilu_r);echo'<li><ahref="'.$titleurl.'">'.$jilu_r['title'].'</a></li>';//此处是修改样式需要图片自己加}}else{echo'暂时浏览记录!';}}//--------------------结束------------------
二:在内容页模版最上面加:
<?=user_SetCook('cookiepro',$navinfor[id],0,10);//cookie名称可以自己定别重复ID时间戳数量?>
三:在要显示的地方加一句:
<?=user_GetCook('cookiepro','shop',10);//名称数据表名数量?>标签帝国历史记录用户
- 上一篇
在帝国cms文章正文里设置超链接自动在新窗口打开的方法
eadminecmseditorinfoeditoreditordialog/fck_link.html查找input id="txtTargetFrame" style="width:100%" type="text" onkeyup="OnTargetNameChange();" onchange="OnTargetNameChange();"改为input id="txtTarget
- 下一篇
在帝国cms列表页调用内容页内容字段newstext
$fr=$empire->fetch1("select newstext from {$dbtbpre}ecms_news_data_{$r[stb]} where id='$r[id]'");$listtemp='<a href="[!--titleurl--]">[!--t