ECSHOP前台添加搜索问题功能
//lib_main.php
function assign_comment($id, $type, $type2=0, $page = 1,$search=false)
{
if($search){
$comment_where = (!empty($type2)) ? " AND content LIKE '%" . mysql_like_quote($type2) . "%' " : '';
}else{
$comment_where= (!empty($type2)) ? " AND comment_type2 = '".$type2."'" : '';
}
/* 取得评论列表 */
$count = $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' .$GLOBALS['ecs']->table('comment').
" WHERE id_value = '$id' AND comment_type = '$type' $comment_where AND status = 1 AND parent_id = 0");
$size = !empty($GLOBALS['_CFG']['comments_number']) ? $GLOBALS['_CFG']['comments_number'] : 5;
$page_count = ($count > 0) ? intval(ceil($count / $size)) : 1;
$sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('comment') .
" WHERE id_value = '$id' AND comment_type = '$type' $comment_where AND status = 1 AND parent_id = 0".
' ORDER BY comment_id DESC';
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page-1) * $size);
$arr = array();
$ids = '';
while ($row = $GLOBALS['db']->fetchRow($res))
{
$ids .= $ids ? ",$row[comment_id]" : $row['comment_id'];
$arr[$row['comment_id']]['id'] = $row['comment_id'];
$arr[$row['comment_id']]['email'] = $row['email'];
$arr[$row['comment_id']]['comment_type2'] = $row['comment_type2'];
$arr[$row['comment_id']]['username'] = $row['user_name'];
$arr[$row['comment_id']]['content'] = str_replace('\r\n', '
', htmlspecialchars($row['content']));
$arr[$row['comment_id']]['content'] = str_replace('\n', '
', $arr[$row['comment_id']]['content']);
$arr[$row['comment_id']]['rank'] = $row['comment_rank'];
$arr[$row['comment_id']]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);
}
/* 取得已有回复的评论 */
if ($ids)
{
$sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('comment') .
" WHERE parent_id IN( $ids )";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetch_array($res))
{
$arr[$row['parent_id']]['re_content'] = str_replace('\n', '
', htmlspecialchars($row['content']));
$arr[$row['parent_id']]['re_add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);
$arr[$row['parent_id']]['re_email'] = $row['email'];
$arr[$row['parent_id']]['re_username'] = $row['user_name'];
}
}
/* 分页样式 */
//$pager['styleid'] = isset($GLOBALS['_CFG']['page_style'])? intval($GLOBALS['_CFG']['page_style']) : 0;
$pager['page'] = $page;
$pager['size'] = $size;
$pager['record_count'] = $count;
$pager['page_count'] = $page_count;
$pager['page_first'] = "javascript:gotoPage(1,$id,$type,$type2)";
$pager['page_prev'] = $page > 1 ? "javascript:gotoPage(" .($page-1). ",$id,$type,$type2)" : 'javascript:;';
$pager['page_next'] = $page < $page_count ? 'javascript:gotoPage(' .($page + 1) . ",$id,$type,$type2)" : 'javascript:;';
$pager['page_last'] = $page < $page_count ? 'javascript:gotoPage(' .$page_count. ",$id,$type,$type2)" : 'javascript:;';
$cmt = array('comments' => $arr, 'pager' => $pager);
return $cmt;
}
//comment.php
/*
* act 参数不为空
* 默认为评论内容列表
* 根据 _GET 创建一个静态对象
*/
$cmt = new stdClass();
$cmt->id = !empty($_GET['id']) ? intval($_GET['id']) : 0;
$cmt->type = !empty($_GET['type']) ? intval($_GET['type']) : 0;
//$cmt->type2 = !empty($_GET['type2']) ? intval($_GET['type2']) : 0;
if(isset($_GET['type2'])){
$cmt->type2 = !empty($_GET['type2']) ? intval($_GET['type2']) : 0;
$search=false;
}else{
$cmt->type2 = !empty($_GET['keyword']) ? trim($_GET['keyword']) : 0;
$cmt->type2 = iconv("UTF-8","GB2312",$cmt->type2);
$search=true;
}
$cmt->page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
}
if ($result['error'] == 0)
{
$comments = assign_comment($cmt->id, $cmt->type, $cmt->type2, $cmt->page,$search);
//因为之前做了评论分频道 所以TYPE2为列表的定位 现在用来做KEYWORDS的入口给 assign_comment 函数
//最后是JS
function searchComment()
{
var keyword = document.getElementById('zx_search').value;
if (keyword.length > 0)
{
Ajax.call('comment.php?act=gotopage', 'page=' + 1 + '&id=' + {$id} + '&type=' + {$comment_type} + '&keyword=' + keyword, gotoPageResponse, 'GET', 'JSON');
}
else
{
document.getElementById('zx_search').focus();
}
}
//lib_main.php
function assign_comment($id, $type, $type2=0, $page = 1,$search=false)
{
if($search){
$comment_where = (!empty($type2)) ? " AND content LIKE '%" . mysql_like_quote($type2) . "%' " : '';
}else{
$comment_where= (!empty($type2)) ? " AND comment_type2 = '".$type2."'" : '';
}
/* 取得评论列表 */
$count = $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' .$GLOBALS['ecs']->table('comment').
" WHERE id_value = '$id' AND comment_type = '$type' $comment_where AND status = 1 AND parent_id = 0");
$size = !empty($GLOBALS['_CFG']['comments_number']) ? $GLOBALS['_CFG']['comments_number'] : 5;
$page_count = ($count > 0) ? intval(ceil($count / $size)) : 1;
$sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('comment') .
" WHERE id_value = '$id' AND comment_type = '$type' $comment_where AND status = 1 AND parent_id = 0".
' ORDER BY comment_id DESC';
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page-1) * $size);
$arr = array();
$ids = '';
while ($row = $GLOBALS['db']->fetchRow($res))
{
$ids .= $ids ? ",$row[comment_id]" : $row['comment_id'];
$arr[$row['comment_id']]['id'] = $row['comment_id'];
$arr[$row['comment_id']]['email'] = $row['email'];
$arr[$row['comment_id']]['comment_type2'] = $row['comment_type2'];
$arr[$row['comment_id']]['username'] = $row['user_name'];
$arr[$row['comment_id']]['content'] = str_replace('\r\n', '
', htmlspecialchars($row['content']));
$arr[$row['comment_id']]['content'] = str_replace('\n', '
', $arr[$row['comment_id']]['content']);
$arr[$row['comment_id']]['rank'] = $row['comment_rank'];
$arr[$row['comment_id']]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);
}
/* 取得已有回复的评论 */
if ($ids)
{
$sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('comment') .
" WHERE parent_id IN( $ids )";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetch_array($res))
{
$arr[$row['parent_id']]['re_content'] = str_replace('\n', '
', htmlspecialchars($row['content']));
$arr[$row['parent_id']]['re_add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);
$arr[$row['parent_id']]['re_email'] = $row['email'];
$arr[$row['parent_id']]['re_username'] = $row['user_name'];
}
}
/* 分页样式 */
//$pager['styleid'] = isset($GLOBALS['_CFG']['page_style'])? intval($GLOBALS['_CFG']['page_style']) : 0;
$pager['page'] = $page;
$pager['size'] = $size;
$pager['record_count'] = $count;
$pager['page_count'] = $page_count;
$pager['page_first'] = "javascript:gotoPage(1,$id,$type,$type2)";
$pager['page_prev'] = $page > 1 ? "javascript:gotoPage(" .($page-1). ",$id,$type,$type2)" : 'javascript:;';
$pager['page_next'] = $page < $page_count ? 'javascript:gotoPage(' .($page + 1) . ",$id,$type,$type2)" : 'javascript:;';
$pager['page_last'] = $page < $page_count ? 'javascript:gotoPage(' .$page_count. ",$id,$type,$type2)" : 'javascript:;';
$cmt = array('comments' => $arr, 'pager' => $pager);
return $cmt;
}
//comment.php
/*
* act 参数不为空
* 默认为评论内容列表
* 根据 _GET 创建一个静态对象
*/
$cmt = new stdClass();
$cmt->id = !empty($_GET['id']) ? intval($_GET['id']) : 0;
$cmt->type = !empty($_GET['type']) ? intval($_GET['type']) : 0;
//$cmt->type2 = !empty($_GET['type2']) ? intval($_GET['type2']) : 0;
if(isset($_GET['type2'])){
$cmt->type2 = !empty($_GET['type2']) ? intval($_GET['type2']) : 0;
$search=false;
}else{
$cmt->type2 = !empty($_GET['keyword']) ? trim($_GET['keyword']) : 0;
$cmt->type2 = iconv("UTF-8","GB2312",$cmt->type2);
$search=true;
}
$cmt->page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
}
if ($result['error'] == 0)
{
$comments = assign_comment($cmt->id, $cmt->type, $cmt->type2, $cmt->page,$search);
//因为之前做了评论分频道 所以TYPE2为列表的定位 现在用来做KEYWORDS的入口给 assign_comment 函数
//最后是JS
function searchComment()
{
var keyword = document.getElementById('zx_search').value;
if (keyword.length > 0)
{
Ajax.call('comment.php?act=gotopage', 'page=' + 1 + '&id=' + {$id} + '&type=' + {$comment_type} + '&keyword=' + keyword, gotoPageResponse, 'GET', 'JSON');
}
else
{
document.getElementById('zx_search').focus();
}
}
ECSHOP-index_get_only_article 指定获取1篇文章
/**
* 获得指定栏目文章内容。
*
* @access private
* @return array
*/
function index_get_only_article($cat_aid)
{
$sql = "SELECT title ,content FROM " .$GLOBALS['ecs']->table('article'). " WHERE article_id = ".$cat_aid." LIMIT 1";
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res AS $row)
{
$arr['title'] = $row['title'];
$arr['content'] = $row['content'];
}
return $arr;
}
/**
* 获得指定栏目文章内容。
*
* @access private
* @return array
*/
function index_get_only_article($cat_aid)
{
$sql = "SELECT title ,content FROM " .$GLOBALS['ecs']->table('article'). " WHERE article_id = ".$cat_aid." LIMIT 1";
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res AS $row)
{
$arr['title'] = $row['title'];
$arr['content'] = $row['content'];
}
return $arr;
}
ecshop支持自定义图片和链接的邮件发送方式
ECSHOP邮件互动性的商城,要求是可以发送要求邮件 而且需要支持图片和外联 这当然需要一个 base64_encode() 来支持发送了 检查了一下 内置了这个函数 那应该没有问题 查看了一下 邮件 被过滤了连接
我用的是FCK编辑器 之前自己开发的时候也用过 提交出来的内容好像是有反斜杠的 于是用 htmlspecialchars()
来测试一下 果然出现了反斜杠,这样就比较容易解决了 一下是我的解决方法 CONTENT是从 FCK里面提交出来的 希望
有需要的人可以用到
$email = trim($_REQUEST['email']);
$content = stripslashes($_REQUEST['saymsg']);//去掉反斜杠函数
$subject = trim($_REQUEST['subject']);
if(!empty($email)){
$email = explode(',', $email);
foreach($email as $value){
if(!empty($value)){
send_mail('', trim($value), $subject , $content,1);
}
}
sys_msg(sprintf("发送成功", htmlspecialchars(stripslashes($_POST['username']))), 0, $link);
}else{
sys_msg(sprintf("邮件为空 发送失败", htmlspecialchars(stripslashes($_POST['username']))), 0, $link);
}
ECSHOP邮件互动性的商城,要求是可以发送要求邮件 而且需要支持图片和外联 这当然需要一个 base64_encode() 来支持发送了 检查了一下 内置了这个函数 那应该没有问题 查看了一下 邮件 被过滤了连接
我用的是FCK编辑器 之前自己开发的时候也用过 提交出来的内容好像是有反斜杠的 于是用 htmlspecialchars()
来测试一下 果然出现了反斜杠,这样就比较容易解决了 一下是我的解决方法 CONTENT是从 FCK里面提交出来的 希望
有需要的人可以用到
$email = trim($_REQUEST['email']);
$content = stripslashes($_REQUEST['saymsg']);//去掉反斜杠函数
$subject = trim($_REQUEST['subject']);
if(!empty($email)){
$email = explode(',', $email);
foreach($email as $value){
if(!empty($value)){
send_mail('', trim($value), $subject , $content,1);
}
}
sys_msg(sprintf("发送成功", htmlspecialchars(stripslashes($_POST['username']))), 0, $link);
}else{
sys_msg(sprintf("邮件为空 发送失败", htmlspecialchars(stripslashes($_POST['username']))), 0, $link);
}
javascript操作复选框函数
function CheckAll(form) {//全选
for (var i=0;i var e = form.elements[i];
if (e.name != 'chkall')
e.checked = form.chkall.checked;
}
}
function checkSelect()//判断是否有选项
{
var pass = false;
var input_elements = document.getElementsByName("Pdel[]");
for ( var i= 0; i< input_elements.length ; i++ )
{
var is_checked = input_elements[i].checked;
var input_name = input_elements[i].getAttribute("name");
var input_type = input_elements[i].getAttribute("type");
if ( input_type == "checkbox" && input_name != "chkall" && true == is_checked )
pass = true;
}
if ( false == pass )
{
alert("请选择要删除的选项!");
return false;
}
else
return true;
}
function selrev() {//反选
with(document.myform) {
for(i=0;i thiselm = elements[i];
if(thiselm.name.match(/dfile\[]/))
thiselm.checked = !thiselm.checked;
}
}
}
function CheckAll(form) {//全选
for (var i=0;i
if (e.name != 'chkall')
e.checked = form.chkall.checked;
}
}
function checkSelect()//判断是否有选项
{
var pass = false;
var input_elements = document.getElementsByName("Pdel[]");
for ( var i= 0; i< input_elements.length ; i++ )
{
var is_checked = input_elements[i].checked;
var input_name = input_elements[i].getAttribute("name");
var input_type = input_elements[i].getAttribute("type");
if ( input_type == "checkbox" && input_name != "chkall" && true == is_checked )
pass = true;
}
if ( false == pass )
{
alert("请选择要删除的选项!");
return false;
}
else
return true;
}
function selrev() {//反选
with(document.myform) {
for(i=0;i
if(thiselm.name.match(/dfile\[]/))
thiselm.checked = !thiselm.checked;
}
}
}
用ECSHOP里的 获得查询时间和次数代码
/**
* 获得查询时间和次数,并赋值给smarty
*
* @access public
* @return void
*/
function assign_query_info()
{
if ($GLOBALS['db']->queryTime == '')
{
$query_time = 0;
}
else
{
if (PHP_VERSION >= '5.0.0')
{
$query_time = number_format(microtime(true) - $GLOBALS['db']->queryTime, 6);
}
else
{
list($now_usec, $now_sec) = explode(' ', microtime());
list($start_usec, $start_sec) = explode(' ', $GLOBALS['db']->queryTime);
$query_time = number_format(($now_sec - $start_sec) + ($now_usec - $start_usec), 6);
}
}
$GLOBALS['smarty']->assign('query_info', sprintf($GLOBALS['_LANG']['query_info'], $GLOBALS['db']->queryCount, $query_time));
/* 内存占用情况 */
if ($GLOBALS['_LANG']['memory_info'] && function_exists('memory_get_usage'))
{
$GLOBALS['smarty']->assign('memory_info', sprintf($GLOBALS['_LANG']['memory_info'], memory_get_usage() / 1048576));
}
/* 是否启用了 gzip */
$gzip_enabled = gzip_enabled() ? $GLOBALS['_LANG']['gzip_enabled'] : $GLOBALS['_LANG']['gzip_disabled'];//这行出错
$GLOBALS['smarty']->assign('gzip_enabled', $gzip_enabled);
}
/**
* 获得查询时间和次数,并赋值给smarty
*
* @access public
* @return void
*/
function assign_query_info()
{
if ($GLOBALS['db']->queryTime == '')
{
$query_time = 0;
}
else
{
if (PHP_VERSION >= '5.0.0')
{
$query_time = number_format(microtime(true) - $GLOBALS['db']->queryTime, 6);
}
else
{
list($now_usec, $now_sec) = explode(' ', microtime());
list($start_usec, $start_sec) = explode(' ', $GLOBALS['db']->queryTime);
$query_time = number_format(($now_sec - $start_sec) + ($now_usec - $start_usec), 6);
}
}
$GLOBALS['smarty']->assign('query_info', sprintf($GLOBALS['_LANG']['query_info'], $GLOBALS['db']->queryCount, $query_time));
/* 内存占用情况 */
if ($GLOBALS['_LANG']['memory_info'] && function_exists('memory_get_usage'))
{
$GLOBALS['smarty']->assign('memory_info', sprintf($GLOBALS['_LANG']['memory_info'], memory_get_usage() / 1048576));
}
/* 是否启用了 gzip */
$gzip_enabled = gzip_enabled() ? $GLOBALS['_LANG']['gzip_enabled'] : $GLOBALS['_LANG']['gzip_disabled'];//这行出错
$GLOBALS['smarty']->assign('gzip_enabled', $gzip_enabled);
}
$smarty->fetch 的使用 生成静态页面
include("Smarty.class.php");$smarty = new Smarty;
$smarty->caching = true;
// only do db calls if cache doesn't exist// 只有在缓存不存在时才调用数据库if(!$smarty->is_cached("index.tpl")){
// dummy up some data $address = "245 N 50th"; $db_data = array( "City" => "Lincoln", "State" => "Nebraska", "Zip" = > "68502" );
$smarty->assign("Name","Fred"); $smarty->assign("Address",$address); $smarty->assign($db_data);
}
// capture the output// 捕获输出$output = $smarty->fetch("index.tpl");
// do something with $output here// 对将要输出的内容进行处理
echo $output;
include("Smarty.class.php");$smarty = new Smarty;
$smarty->caching = true;
// only do db calls if cache doesn't exist// 只有在缓存不存在时才调用数据库if(!$smarty->is_cached("index.tpl")){
// dummy up some data $address = "245 N 50th"; $db_data = array( "City" => "Lincoln", "State" => "Nebraska", "Zip" = > "68502" );
$smarty->assign("Name","Fred"); $smarty->assign("Address",$address); $smarty->assign($db_data);
}
// capture the output// 捕获输出$output = $smarty->fetch("index.tpl");
// do something with $output here// 对将要输出的内容进行处理
echo $output;
修改ecshop后台的版权信息
在languages/zh_cn/admin/common.php文件修改
admin/templates/index.htm
Line 4
*/
{$lang.cp_home}
/*
admin/templates/login.htm
Line 4
*/
{$lang.cp_home}
/*
admin/templates/top.htm
Line 132
Line 135
*/
{$lang.about}
/*
admin/templates/start.htm
Line 6
*/
/*
Line 184-195
*/
{$lang.ecs_version}
{$ecs_version} RELEASE {$ecs_release}
{$lang.install_date}
{$install_date}
{$lang.ec_charset}
{$ecs_charset}
/*
admin/tempaltes/pageheader.htm
Line 24
*/
{$lang.cp_home} {if $ur_here} - {$ur_here} {/if}
/*
admin/templates/pagefooter.htm
Line 3
*/
{$lang.copyright}
/*
admin/templates/menu.htm
Line 143
*/
在languages/zh_cn/admin/common.php文件修改
admin/templates/index.htm
Line 4
*/
/*
admin/templates/login.htm
Line 4
*/
/*
admin/templates/top.htm
Line 132
Line 135
*/
< img src=”images/ecshop_logo.gif” alt=”ECSHOP - power for e-commerce” />
/*
admin/templates/start.htm
Line 6
*/
/*
Line 184-195
*/
/*
admin/tempaltes/pageheader.htm
Line 24
*/
{$lang.cp_home} {if $ur_here} - {$ur_here} {/if}
/*
admin/templates/pagefooter.htm
Line 3
*/
{$lang.copyright}
/*
admin/templates/menu.htm
Line 143
*/
ECSHOP获得指定栏目最新的商品列表
/**
* 获得指定栏目最新的商品列表。
*
* @access private
* @return array
*/
function index_get_class_goods($cat_aid, $cat_num)
{
$sql = "SELECT goods_id FROM " .$GLOBALS['ecs']->table('goods'). "WHERE (cat_id = ".$cat_aid." OR goods_id in (".good_cat_id($cat_aid).") ) and is_on_sale = 1 order by `last_update` desc LIMIT " . $cat_num;
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res AS $idx => $row)
{
$arr[$idx]['id'] = $row['goods_id'];
$arr[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']));
}
return $arr;
}
function good_cat_id($cat_aid){
$sql = "SELECT goods_id FROM " .$GLOBALS['ecs']->table('goods_cat'). " WHERE cat_id = ".$cat_aid;
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res AS $row)
{
$arr[] = $row['goods_id'];
}
$ck_explode=implode(',',$arr);
return $ck_explode;
}
在
$smarty->assign(’shop_notice’, $_CFG['shop_notice']); // 商店公告
加上
$smarty->assign(’news_goods’, index_get_class_goods(18,4)); // 新品快递
$smarty->assign(’design_recommend’, index_get_class_goods(35,4)); // 设计师推荐
指定函数定义放到HTML里就可以了
/**
* 获得指定栏目最新的商品列表。
*
* @access private
* @return array
*/
function index_get_class_goods($cat_aid, $cat_num)
{
$sql = "SELECT goods_id FROM " .$GLOBALS['ecs']->table('goods'). "WHERE (cat_id = ".$cat_aid." OR goods_id in (".good_cat_id($cat_aid).") ) and is_on_sale = 1 order by `last_update` desc LIMIT " . $cat_num;
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res AS $idx => $row)
{
$arr[$idx]['id'] = $row['goods_id'];
$arr[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']));
}
return $arr;
}
function good_cat_id($cat_aid){
$sql = "SELECT goods_id FROM " .$GLOBALS['ecs']->table('goods_cat'). " WHERE cat_id = ".$cat_aid;
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res AS $row)
{
$arr[] = $row['goods_id'];
}
$ck_explode=implode(',',$arr);
return $ck_explode;
}
在
$smarty->assign(’shop_notice’, $_CFG['shop_notice']); // 商店公告
加上
$smarty->assign(’news_goods’, index_get_class_goods(18,4)); // 新品快递
$smarty->assign(’design_recommend’, index_get_class_goods(35,4)); // 设计师推荐
指定函数定义放到HTML里就可以了
ECSHOP调用分类文章函数index_get_class_articles
/**
* 获得指定栏目最新的文章列表。
*
* @access private
* @return array
*/
function index_get_class_articles($cat_aid, $cat_num)
{
$sql = "SELECT article_id, title,open_type,cat_id,file_url FROM " .$GLOBALS['ecs']->table('article'). " WHERE cat_id = ".$cat_aid." and is_open = 1 LIMIT " . $cat_num;
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res AS $idx => $row)
{
$arr[$idx]['id'] = $row['article_id'];
$arr[$idx]['title'] = $row['title'];
$arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ?
sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
$arr[$idx]['cat_name'] = $row['cat_name'];
$arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
$arr[$idx]['url'] = $row['open_type'] != 1 ?
build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
$arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']));
}
return $arr;
}
2、第二步是在index.dwt模板想调用的地方增加以下代码,(注:以下调上面设置里的分类ID为8的文章列表):
/**
* 获得指定栏目最新的文章列表。
*
* @access private
* @return array
*/
function index_get_class_articles($cat_aid, $cat_num)
{
$sql = "SELECT article_id, title,open_type,cat_id,file_url FROM " .$GLOBALS['ecs']->table('article'). " WHERE cat_id = ".$cat_aid." and is_open = 1 LIMIT " . $cat_num;
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res AS $idx => $row)
{
$arr[$idx]['id'] = $row['article_id'];
$arr[$idx]['title'] = $row['title'];
$arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ?
sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
$arr[$idx]['cat_name'] = $row['cat_name'];
$arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
$arr[$idx]['url'] = $row['open_type'] != 1 ?
build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
$arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']));
}
return $arr;
}
2、第二步是在index.dwt模板想调用的地方增加以下代码,(注:以下调上面设置里的分类ID为8的文章列表):
ecshop会员中心订单搜索功能
在user.php中的act=order_list中增加以下程序。
$order_sn = isset($_REQUEST['order_sn'])?$_REQUEST['order_sn']:'';
$consignee = isset($_REQUEST['consignee'])?$_REQUEST['consignee']:'';
$start_date = isset($_REQUEST['start_date'])?$_REQUEST['start_date']:'';
$end_date = isset($_REQUEST['end_date'])?$_REQUEST['end_date']:'';
$pay_status = isset($_REQUEST['pay_status'])?$_REQUEST['pay_status']:'';
$shipping_status = isset($_REQUEST['shipping_status'])?$_REQUEST['shipping_status']:'';
$order_status = isset($_REQUEST['order_status'])?$_REQUEST['order_status']:'';
$where ="";
if($order_sn){
$where.=" and order_sn ='$order_sn'";
}
if($consignee){
$where.=" and consignee = '$$consignee'";
}
if($start_date){
$t = strtotime($start_date);
$where.=" and add_time >= $t";
}
if($end_date){
$t = strtotime($end_date);
$where.=" and add_time <= $t";
}
if($pay_status && $pay_status!= '-1'){
$where.=" pay_status = '$pay_status'";
}
if($shipping_status && $shipping_status!= '-1'){
$where.=" and shipping_status = '$shipping_status'";
}
if($order_status && $order_status!= '-1'){
$where.=" and order_status = '$order_status'";
}
$record_count = $db->getOne("SELECT COUNT(*) FROM " .$ecs->table('order_info'). " WHERE user_id = '$user_id' $where");
$pager = get_pager('user.php', array('act' => $action,'order_status'=>$order_status,'order_sn'=>$order_sn,'consignee'=>$consignee,'start_date'=>$start_date,'end_date'=>$end_date,'pay_status'=>$pay_status,'shipping_status'=>$shipping_status), $record_count, $page);
$orders = get_user_orders($user_id, $pager['size'], $pager['start']);
$merge = get_user_merge($user_id);
$smarty->assign('os_list', get_status_list('order'));
$smarty->assign('ps_list', get_status_list('payment'));
$smarty->assign('ss_list', get_status_list('shipping'));
$smarty->assign('merge', $merge);
$smarty->assign('pager', $pager);
$smarty->assign('orders', $orders);
$smarty->display('user_transaction.dwt');
在分页模板中,传递要查询的参数。
2:模板中增加以下程序。用于搜索表单
<link href="js/calendar/calendar.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/calendar.php"></script>
<tr align="center">
<td bgcolor="#ffffff" colspan="5"><div align="left">订单编号
<input type="hidden" name="act" value="order_list">
<input type="text" name="order_sn"><br>
收货人姓名
<input type="text" name="consignee">
<br>
下单时间 <input name="start_date" value="{$start_date}" style="width:80px;" onclick="return showCalendar(this, '%Y-%m-%d', false, false, this);" />
-
<input name="end_date" value="{$end_date}" style="width:80px;" onclick="return showCalendar(this, '%Y-%m-%d', false, false, this);" />
<br>
订单状态: <select name="order_status" id="select9">
<option value="-1">请选择</option>
{html_options options=$os_list selected=-1}
</select>
付款状态: <select name="pay_status" id="select11">
<option value="-1">请选择</option>
{html_options options=$ps_list selected=-1}
</select>
发货状态: <select name="shipping_status" id="select10">
<option value="-1">请选择</option>
{html_options options=$ss_list selected=-1}
</select> <input type="submit" value="搜索"></div></td>
</tr>
3:将以下搜索条件加到搜索函数中去。在includes/lib_transaction.php中ecshop函数get_user_orders()中
$order_sn = isset($_REQUEST['order_sn'])?$_REQUEST['order_sn']:'';
$consignee = isset($_REQUEST['consignee'])?$_REQUEST['consignee']:'';
$start_date = isset($_REQUEST['start_date'])?$_REQUEST['start_date']:'';
$end_date = isset($_REQUEST['end_date'])?$_REQUEST['end_date']:'';
$pay_status = isset($_REQUEST['pay_status'])?$_REQUEST['pay_status']:'';
$shipping_status = isset($_REQUEST['shipping_status'])?$_REQUEST['shipping_status']:'';
$order_status = isset($_REQUEST['order_status'])?$_REQUEST['order_status']:'';
$where ="";
if($order_sn){
$where.=" and order_sn ='$order_sn'";
}
if($consignee){
$where.=" and consignee = '$$consignee'";
}
if($start_date){
$t = strtotime($start_date);
$where.=" and add_time >= $t";
}
if($end_date){
$t = strtotime($end_date);
$where.=" and add_time <= $t";
}
if($pay_status && $pay_status!= '-1'){
$where.=" pay_status = '$pay_status'";
}
if($shipping_status && $shipping_status!= '-1'){
$where.=" and shipping_status = '$shipping_status'";
}
if($order_status && $order_status!= '-1'){
$where.=" and order_status = '$order_status'";
}
在user.php中的act=order_list中增加以下程序。
$order_sn = isset($_REQUEST['order_sn'])?$_REQUEST['order_sn']:'';
$consignee = isset($_REQUEST['consignee'])?$_REQUEST['consignee']:'';
$start_date = isset($_REQUEST['start_date'])?$_REQUEST['start_date']:'';
$end_date = isset($_REQUEST['end_date'])?$_REQUEST['end_date']:'';
$pay_status = isset($_REQUEST['pay_status'])?$_REQUEST['pay_status']:'';
$shipping_status = isset($_REQUEST['shipping_status'])?$_REQUEST['shipping_status']:'';
$order_status = isset($_REQUEST['order_status'])?$_REQUEST['order_status']:'';
$where ="";
if($order_sn){
$where.=" and order_sn ='$order_sn'";
}
if($consignee){
$where.=" and consignee = '$$consignee'";
}
if($start_date){
$t = strtotime($start_date);
$where.=" and add_time >= $t";
}
if($end_date){
$t = strtotime($end_date);
$where.=" and add_time <= $t";
}
if($pay_status && $pay_status!= '-1'){
$where.=" pay_status = '$pay_status'";
}
if($shipping_status && $shipping_status!= '-1'){
$where.=" and shipping_status = '$shipping_status'";
}
if($order_status && $order_status!= '-1'){
$where.=" and order_status = '$order_status'";
}
$record_count = $db->getOne("SELECT COUNT(*) FROM " .$ecs->table('order_info'). " WHERE user_id = '$user_id' $where");
$pager = get_pager('user.php', array('act' => $action,'order_status'=>$order_status,'order_sn'=>$order_sn,'consignee'=>$consignee,'start_date'=>$start_date,'end_date'=>$end_date,'pay_status'=>$pay_status,'shipping_status'=>$shipping_status), $record_count, $page);
$orders = get_user_orders($user_id, $pager['size'], $pager['start']);
$merge = get_user_merge($user_id);
$smarty->assign('os_list', get_status_list('order'));
$smarty->assign('ps_list', get_status_list('payment'));
$smarty->assign('ss_list', get_status_list('shipping'));
$smarty->assign('merge', $merge);
$smarty->assign('pager', $pager);
$smarty->assign('orders', $orders);
$smarty->display('user_transaction.dwt');
在分页模板中,传递要查询的参数。
2:模板中增加以下程序。用于搜索表单
<link href="js/calendar/calendar.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/calendar.php"></script>
<tr align="center">
<td bgcolor="#ffffff" colspan="5"><div align="left">订单编号
<input type="hidden" name="act" value="order_list">
<input type="text" name="order_sn"><br>
收货人姓名
<input type="text" name="consignee">
<br>
下单时间 <input name="start_date" value="{$start_date}" style="width:80px;" onclick="return showCalendar(this, '%Y-%m-%d', false, false, this);" />
-
<input name="end_date" value="{$end_date}" style="width:80px;" onclick="return showCalendar(this, '%Y-%m-%d', false, false, this);" />
<br>
订单状态: <select name="order_status" id="select9">
<option value="-1">请选择</option>
{html_options options=$os_list selected=-1}
</select>
付款状态: <select name="pay_status" id="select11">
<option value="-1">请选择</option>
{html_options options=$ps_list selected=-1}
</select>
发货状态: <select name="shipping_status" id="select10">
<option value="-1">请选择</option>
{html_options options=$ss_list selected=-1}
</select> <input type="submit" value="搜索"></div></td>
</tr>
3:将以下搜索条件加到搜索函数中去。在includes/lib_transaction.php中ecshop函数get_user_orders()中
$order_sn = isset($_REQUEST['order_sn'])?$_REQUEST['order_sn']:'';
$consignee = isset($_REQUEST['consignee'])?$_REQUEST['consignee']:'';
$start_date = isset($_REQUEST['start_date'])?$_REQUEST['start_date']:'';
$end_date = isset($_REQUEST['end_date'])?$_REQUEST['end_date']:'';
$pay_status = isset($_REQUEST['pay_status'])?$_REQUEST['pay_status']:'';
$shipping_status = isset($_REQUEST['shipping_status'])?$_REQUEST['shipping_status']:'';
$order_status = isset($_REQUEST['order_status'])?$_REQUEST['order_status']:'';
$where ="";
if($order_sn){
$where.=" and order_sn ='$order_sn'";
}
if($consignee){
$where.=" and consignee = '$$consignee'";
}
if($start_date){
$t = strtotime($start_date);
$where.=" and add_time >= $t";
}
if($end_date){
$t = strtotime($end_date);
$where.=" and add_time <= $t";
}
if($pay_status && $pay_status!= '-1'){
$where.=" pay_status = '$pay_status'";
}
if($shipping_status && $shipping_status!= '-1'){
$where.=" and shipping_status = '$shipping_status'";
}
if($order_status && $order_status!= '-1'){
$where.=" and order_status = '$order_status'";
}




2009
11:39
1636
0

