
让ecshop也支持在线测试模块功能.doc
6页在网上,我们不难发现一些测试网,什么星运测试,爱情测试,美容测试;如果能添加一个测试功能,并能在些测试结果推荐相关产品,也是一个不错不营销活动方式本文以现在给商场添加制作的“皮肤测试”功能为例,制作过程如下:1. 后台添加自定义导航2.添加模板文件 test.dwt(测试问题页)效果图如下1. 您的性别 男 女 2. 您的年龄 18 岁以下 18 岁以上3. 您长痘的时间 1 年以下 1 年以上4. 您的痘痘严重吗? 严重 不严重5. 您的痘坑多吗? 多 少6. 您的痘痘是否化脓? 是 否3.添加模板文件 test_result.dwt(测试结果页)代码略,根据网站要求而定{$goods.goods_style_name} {$goods.goods_name} 市场价:{$goods.market_price}代码略,根据网站要求而定4.系统根目录添加 test.php 文件//常规引用define('IN_ECS', true);require(dirname(__FILE__) . '/includes/init.php');if ((DEBUG_MODE & 2) != 2){$smarty->caching = true;}$ua = strtolower($_SERVER['HTTP_USER_AGENT']);$uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i";/* 显示页面的 action 列表 */$ui_arr = array('default','dd_test','dy_test','pf_test');if(($ua == '' || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap')){$Loaction = 'mobile/';if (!empty($Loaction)){ecs_header("Location: $Loaction\n");exit;}}/*------------------------------------------------------ *///-- Shopex 系统地址转换/*------------------------------------------------------ */if (!empty($_GET['gOo'])){if (!empty($_GET['gcat'])){/* 商品分类。
/$Loaction = 'category.php?id=' . $_GET['gcat'];}elseif (!empty($_GET['acat'])){/* 文章分类/$Loaction = 'article_cat.php?id=' . $_GET['acat'];}elseif (!empty($_GET['goodsid'])){/* 商品详情/$Loaction = 'goods.php?id=' . $_GET['goodsid'];}elseif (!empty($_GET['articleid'])){/* 文章详情/$Loaction = 'article.php?id=' . $_GET['articleid'];}if (!empty($Loaction)){ecs_header("Location: $Loaction\n");exit;}}//判断是否有 ajax 请求$act = (!empty($_POST['act']) )? $_POST['act'] : 'default';$val=$_REQUEST['val'];if(in_array($act, $ui_arr)){assign_template();$position = assign_ur_here();$smarty->assign('page_title', $position['title']); // 页面标题$smarty->assign('ur_here', $position['ur_here']); // 当前位置/* meta information */ $smarty->assign('keywords', htmlspecialchars($_CFG['shop_keywords']));$smarty->assign('description', htmlspecialchars($_CFG['shop_desc']));$smarty->assign('feed_url', ($_CFG['rewrite'] == 1) ? 'feed.xml' : 'feed.php'); // RSS URL$smarty->assign('categories', get_categories_tree()); // 分类树/* 页面中的动态内容 */assign_dynamic('index');}if ($act == 'default'){$test_type=!empty($_REQUEST['type'])?$_REQUEST['type']:'';$smarty->assign('type',$test_type);$smarty->display('test.dwt', $cache_id);}//以下是测试规则部分(视实际需定)if ($act == 'dd_test'){$total=0;if( !empty($val)){foreach($val as $key=>$v){if((int)($v)==1){$total+=2;}else if((int)($v)==2){$total+=1;}}}else{$total=0;}if($totalassign('type',$act);$smarty->display('test_result_error.dwt');exit();}$result=get_dd_result($total);//根据测试规则获取测试结果类型,并返回推荐产品(推荐条件自定义)$smarty->assign('result_type',$result['result_type']); $smarty->assign('recommended',$result['recommended']);$smarty->assign('fittings',$result['fittings']); $smarty->display('test_result.dwt');}更多内容请访问 fenfenglee 博客。
