共享sensorforyou的最近浏览过的产品功能
07月 25th, 2008很简单的一个功能,就是在产品内容页面放入一段代码,把当前的产品id放到cookie中,当检查到cookie中有相应的值时,就把他按自己的样子显示出来
1。在includes/modules/pages/product_info/header_php.php 中加入以下代码,以写cookie
if($_GET[’products_id’] != ”) {
if(!isset($_COOKIE[’product_history’]) ) {
$history_array = (int)$_GET[’products_id’];
zen_setcookie(’product_history’, $history_array, time()+60*60*24*30, ‘/’, ‘www.sensorforyou.com’);
} else {
$history_array = explode(’,',$_COOKIE[’product_history’]);
array_unshift($history_array,(int)$_GET[’products_id’]);
$history_array = array_unique($history_array);
if(count($history_array) > 6)
array_pop($history_array);
zen_setcookie(’product_history’, implode(’,',$history_array), time()+60*60*24*30, ‘/’, ‘www.sensorforyou.com’);
}
}
注意要自己把zen_setcookie函数的域名参数改为自己的域名 Read the rest of this entry »