关于ecshop的那些故事
1.php下foreach()错误提示Warning: Invalid argument supplied for foreach()
错误提示:Warning: Invalid argument supplied for foreach() in E:wampwwwmyshopcart.php on line 95
二、解决方案:
错误提示 Warning:Invalid argument supplied for foreach() 的中文意思是说foreach需要是一个数组而给它的是一个无效的参数.
就是在循环前面加上判断,直接使用is_array判断给的值是不是为数组,代码如下:
复制代码 代码如下:
if(is_array($items) && !emptyempty($items)){
foreach( )
}
或者强制转换数据类型,代码如下:
复制代码 代码如下:
foreach((array)$v as $k1 => $v1) {
$edu[$k1][$k] = my_h($v1);// v1是最终要入库的数据,进行转义处理
}
2.后台添加导航的错误
http://www.bcty365.com/content-104-2007-1.html
3.首页显示分类产品列表
在lib_goods.php里加个这个
/**
* 首页获取指定分类产品
*
* @access public
* @param string
* @param array
* @return array
*/
function get_cat_id_goods_list($cat_id = '', $num = '') {
$sql = 'Select g.goods_id, g.cat_id,c.parent_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, " .
"promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " .
"g.is_best, g.is_new, g.is_hot, g.is_promote " .
'FROM ' . $GLOBALS ['ecs']->table ( 'goods' ) . ' AS g ' .
'LEFT JOIN ' . $GLOBALS ['ecs']->table ( 'category' ) . ' AS c ON c.cat_id = g.cat_id ' .
"LEFT JOIN " . $GLOBALS ['ecs']->table ( 'member_price' ) . " AS mp " .
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
"Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " .
$sql .= " AND (c.parent_id =" . $cat_id . " OR g.cat_id = " . $cat_id . " OR g.cat_id " . db_create_in ( array_unique ( array_merge ( array (
$cat_id
), array_keys ( cat_list ( $cat_id, 0, false ) ) ) ) ) . ")";
$sql .= " LIMIT $num";
$res = $GLOBALS ['db']->getAll ( $sql );
$goods = array ();
foreach ( $res as $idx => $row ) {
$goods [$idx] ['id'] = $row ['article_id'];
$goods [$idx] ['id'] = $row ['goods_id'];
$goods [$idx] ['name'] = $row ['goods_name'];
$goods [$idx] ['brief'] = $row ['goods_brief'];
$goods [$idx] ['brand_name'] = $row ['brand_name'];
$goods [$idx] ['goods_style_name'] = add_style ( $row ['goods_name'], $row ['goods_name_style'] );
$goods [$idx] ['short_name'] = $GLOBALS ['_CFG'] ['goods_name_length'] > 0 ? sub_str ( $row ['goods_name'], $GLOBALS ['_CFG'] ['goods_name_length'] ) : $row ['goods_name'];
$goods [$idx] ['short_style_name'] = add_style ( $goods [$idx] ['short_name'], $row ['goods_name_style'] );
$goods [$idx] ['market_price'] = price_format ( $row ['market_price'] );
$goods [$idx] ['shop_price'] = price_format ( $row ['shop_price'] );
$goods [$idx] ['thumb'] = empty ( $row ['goods_thumb'] ) ? $GLOBALS ['_CFG'] ['no_picture'] : $row ['goods_thumb'];
$goods [$idx] ['goods_img'] = empty ( $row ['goods_img'] ) ? $GLOBALS ['_CFG'] ['no_picture'] : $row ['goods_img'];
$goods [$idx] ['url'] = build_uri ( 'goods', array (
'gid' => $row ['goods_id']
), $row ['goods_name'] );
}
return $goods;
}
然后是index.php输出
$smarty->assign('cat_id_goods_list_19', get_cat_id_goods_list(19,10));//进口水果额
最后前台一遍历
4.首页显示文章上传的file_url字段 来当图片用
在对应的php方法里加个 file_url字段即可
5.后台添加导航碰到这个错误 咋整
解决下:上面代码可以输出值,但是报错Warning: Illegal string offset 'cat_name' in ,原因是$catlist数组里面有空数组,空数组里没有cat_name这个字段。最终解决办法是在 foreach 下面加个判断 if(is_array($val)),这样就搞定了。
6.登陆的时候 登陆没通过 有错误
构造函数放到方法上面就好了
7.Ecshop 如何在全站都调用购物车信息 比如买了几件 一共多少钱
http://www.cnblogs.com/wangblognet/archive/2013/01/23/2873333.html
8.文章列表页如何显示网页描述字段
http://www.68ecshop.com/article-933.html
9.登陆注册页面显示产品分类列表
根目录的user.php 里大概79行 加一句这个
$smarty->assign('categories', get_categories_tree()); // 分类树
10. Strict Standards: mktime(): You should be using the time() function instead in E:\web\shopex\admin\shop_config.php on line 32
这个错误提示的意思:mktime()方法不带参数被调用时,会被抛出一个报错提示。
找到文件第32行:
$auth = mktime();
将mktime()替换成time()方法,代码为:
$auth = time();
11. Strict standards: Redefining already defined constructor for class cls_sql_dump in
调换一下两个函数的前后位置即可。
以 includes/modules/payment/alipay.php 为例:
将下面这两个函数的位置互换一下就OK了,__c**truct()在前,alipay()在后
- function alipay() {
- }
- function __c**truct()
- {
- $this->alipay();
- }
12. Strict standards: Non-static method cls_sql_dump::get_random_name() should not be called statically
13.上传的图片不清楚怎么办
http://www.51php.com/ecshop/13916.html
按照路径直接找到根目录下thems/default/goods.dwt这个文件 直接修改模板文件即可
找到:
<div class=”good_img”>
<a href=”javascript:;” onclick=”window.open(‘gallery.php?id={$goods.goods_id}’); return false;” >
<img src=”{$goods.goods_img}” alt=”{$goods.goods_name|escape:html}” id=”goodsimg” style=”width:340px;” />
</a>
</div>
修改为:
<div class=”good_img”>
<a href=”javascript:;” onclick=”window.open(‘gallery.php?id={$goods.goods_id}’); return false;” >
<img src=”{$goods.original_img}” alt=”{$goods.goods_name|escape:html}” id=”goodsimg” style=”width:340px;” />
</a>
</div>