ecshop 文章缩略图怎么根据颜色按钮,左边只显示颜色对应的缩略图

ecshop基本操作_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
文档贡献者
评价文档:
ecshop基本操作
e​c​s​h​o​p​的​最​基​本​的​操​作​方​法​,​模​版​的​简​单​制​作​,​以​及​一​些​细​节​问​题​的​介​绍​!​!​!
大小:15.11KB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢ecshop&仿淘宝颜色属性可上传图片功能,前台颜色可以用图
/love/item/ff56c634bc6ad341033edc1a
代码中红色部分为添加和修改的内容!!
首先在在ecs_goods_attr数据表中添加&字段&attr_img&(数据类型为varchar)
一、打开文件:admin/include/lib_goods.php
function&build_attr_html($cat_id,&$goods_id&=&0)
&&&&$attr&=&get_attr_list($cat_id,&$goods_id);
&&&&$html&=&'';
&&&&$spec&=&0;
&&&&foreach&($attr&AS&$key&=&&$val)
&&&&&&&&$html&.=&"
&&&&&&&&if&($val['attr_type']&==&1&||&$val['attr_type']&==&2)
&&&&&&&&&&&&$html&.=&($spec&!=&$val['attr_id'])&?
&&&&&&&&&&&&&&&&"[+]"&:
&&&&&&&&&&&&&&&&"[-]";
&&&&&&&&&&&&$spec&=&$val['attr_id'];
&&&&&&&&$html&.=&"$val[attr_name]
&&&&$html&.=&'';
&&&&return&$
二、admin/goods.php
&//&循环现有的,根据原有的做相应处理
if(isset($_POST['attr_id_list']))
& & foreach
($_POST['attr_id_list'] AS $key =& $attr_id)
//上传文件类型列表
&$uptypes=array(
& &'image/jpg',
& &'image/jpeg',
& &'image/png',
& &'image/pjpeg',
& &'image/gif',
& &'image/bmp',
& &'image/x-png'
&$datetime=date("Ym",time());
&$max_file_size=5000000; &
& //上传文件大小限制, 单位BYTE
&$destination_folder="../images/img/".$datetime."/";
//上传文件路径
&$destination_folder1="images/img/".$datetime."/";
//写入数据库文件路径
&if(!$_FILES['attr_img_list']['error'] &
&$attr_img='';
if($_FILES['attr_img_list']['name'][$key]==''){
& if($_POST['img'][$key]!=''){
$attr_img=$_POST['img'][$key];
& & $attr_img='';
$aa=time().$_FILES['attr_img_list']['name'][$key];
$filename=$_FILES["attr_img_list"]["tmp_name"][$key];
$image_size = getimagesize($filename);
(!is_uploaded_file($filename))
//是否存在文件
&if($max_file_size & $image_size)
&//检查文件大小
& & echo "
&if(!in_array($_FILES["attr_img_list"]["type"][$key],
$uptypes))
&//检查文件类型
if(!file_exists($destination_folder))
&mkdir($destination_folder);
$pinfo=pathinfo($_FILES['attr_img_list']['name'][$key]);
$ftype=$pinfo['extension'];
& & if($ftype==''){
$attr_img='';
$destination = $destination_folder.$
&$pinfo=pathinfo($destination);
&$fname=$pinfo[basename];
& &$destination =
$destination_folder.$
& &if (file_exists($destination)
&& $overwrite != true)
& & & echo
& &if(!move_uploaded_file
($filename,$destination))
$attr_img=$destination_folder1.$
&&&&&&&&&&&&&&&&$attr_value&=&$_POST['attr_value_list'][$key];
&&&&&&&&&&&&&&&&$attr_price&=&$_POST['attr_price_list'][$key];
&&&&&&&&&&&&&&&&if&(!empty($attr_value))
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&if&(isset($goods_attr_list[$attr_id][$attr_value]))
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&//&如果原来有,标记为更新
&&&&&&&&&&&&&&&&&&&&&&&&$goods_attr_list[$attr_id][$attr_value]['sign']&=&'update';
&&&&&&&&&&&&&&&&&&&&&&&&$goods_attr_list[$attr_id][$attr_value]['attr_price']&=&$attr_
&&&&&&&&&&&&&&&&&&&&&&&&$goods_attr_list[$attr_id][$attr_value]['attr_img']&=&$attr_
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&else
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&//&如果原来没有,标记为新增
&&&&&&&&&&&&&&&&&&&&&&&&$goods_attr_list[$attr_id][$attr_value]['sign']&=&'insert';
&&&&&&&&&&&&&&&&&&&&&&&&$goods_attr_list[$attr_id][$attr_value]['attr_price']&=&$attr_
&&&&&&&&&&&&&&&&&&&&&&&&$goods_attr_list[$attr_id][$attr_value]['attr_img']&&&=&$attr_
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&$val_arr&=&explode('&',&$attr_value);
&&&&&&&&&&&&&&&&&&&&foreach&($val_arr&AS&$k&=&&$v)
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&if&(!isset($keywords_arr[$v])&&&&$attr_list[$attr_id]&==&"1")
&&&&&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&$keywords_arr[$v]&=&$v;
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&$keywords&=&join('&',&array_flip($keywords_arr));
&&&&&&&&$sql&=&"UPDATE&"&.$ecs-&table('goods').&"&SET&keywords&=&'$keywords'&WHERE&goods_id&=&'$goods_id'&LIMIT&1";
&&&&&&&&$db-&query($sql);
&&&&&&&&foreach&($goods_attr_list&as&$attr_id&=&&$attr_value_list)
&&&&&&&&&&&&foreach&($attr_value_list&as&$attr_value&=&&$info)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&if&($info['sign']&==&'insert')
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&$sql&=&"INSERT&INTO&"&.$ecs-&table('goods_attr').&"&(attr_id,&goods_id,&attr_value,&attr_price,&attr_img)".
&&&&&&&&&&&&&&&&&&&&&&&&&&&&"VALUES&('$attr_id',&'$goods_id',&'$attr_value',&'$info[attr_price]',&'$info[attr_img]')";
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&elseif&($info['sign']&==&'update')
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&$sql&=&"UPDATE&"&.$ecs-&table('goods_attr').&"&SET&attr_price&=&'$info[attr_price]',attr_img&=&'$info[attr_img]'WHERE&goods_attr_id&=&'$info[goods_attr_id]'&LIMIT&1";
&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&else
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&$sql&=&"DELETE&FROM&"&.$ecs-&table('goods_attr').&"&WHERE&goods_attr_id&=&'$info[goods_attr_id]'&LIMIT&1";
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&$db-&query($sql);
&&&&&&&&&&&&}
前台页面部分:
1、修改goods.dwt文件
&&&&&&&&if&($val['attr_input_type']&==&0)
&&&&&&&&&&&&$html&.=&'&';
&&&&&&&&elseif&($val['attr_input_type']&==&2)
&&&&&&&&&&&&$html&.=&''&.htmlspecialchars($val['attr_value']).&'';
&&&&&&&&else
&&&&&&&&&&&&$html&.=&'';
&&&&&&&&&&&&$html&.=&''&.$GLOBALS['_LANG']['select_please'].&'';
&&&&&&&&&&&&$attr_values&=&explode("\n",&$val['attr_values']);
&&&&&&&&&&&&foreach&($attr_values&AS&$opt)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&$opt&&&&=&trim(htmlspecialchars($opt));
&&&&&&&&&&&&&&&&$html&&&.=&($val['attr_value']&!=&$opt)&?
&&&&&&&&&&&&&&&&&&&&''&.&$opt&.&''&:
&&&&&&&&&&&&&&&&&&&&''&.&$opt&.&'';
&&&&&&&&&&&&}
&&&&&&&&&&&&$html&.=&'&';
if($val['attr_img']==""){
&$html .= ($val['attr_type'] == 1 ||
$val['attr_type'] == 2) ?
$GLOBALS['_LANG']['spec_price'].' &
& & 属性图片:
图片尺寸: 800*800px &
&$html .= ($val['attr_type'] == 1 ||
$val['attr_type'] == 2) ?
$GLOBALS['_LANG']['spec_price'].' &
& & 属性图片:
图片尺寸: 800*800px &<img BORDER="0"
ALT="ecshop&仿淘宝颜色属性可上传图片功能,前台颜色可以用图"
TITLE="ecshop&仿淘宝颜色属性可上传图片功能,前台颜色可以用图" />':
&&&&&&&&$html&.=&'
2、修改lib_goods.php文件下的get_goods_properties()函数
function get_goods_properties($goods_id)
& & $sql = "SELECT attr_group
& & & "FROM " .
$GLOBALS['ecs']-&table('goods_type') . " AS gt, " .
$GLOBALS['ecs']-&table('goods') . " AS g ".
& & & "WHERE
g.goods_id='$goods_id' AND gt.cat_id=g.goods_type";
& & $grp =
$GLOBALS['db']-&getOne($sql);
& & if (!empty($grp))
& $groups = explode("\n", strtr($grp, "\r",
& & $sql = "SELECT a.attr_id,
a.attr_name, a.attr_group, a.is_linked, a.attr_type, ".
& & "g.goods_attr_id,
g.attr_value, g.attr_price,&g.attr_img&" .
& & & 'FROM ' .
$GLOBALS['ecs']-&table('goods_attr') . ' AS g ' .
& & & 'LEFT JOIN
' . $GLOBALS['ecs']-&table('attribute') . ' AS a ON a.attr_id =
g.attr_id ' .
& & & "WHERE
g.goods_id = '$goods_id' " .
& & & 'ORDER BY
a.sort_order, g.attr_price, g.goods_attr_id';
& & $res =
$GLOBALS['db']-&getAll($sql);
& & $arr['pro'] = array();
& & // 属性
& & $arr['spe'] = array();
& & // 规格
& & $arr['lnk'] = array();
& & // 关联的属性
& & foreach ($res AS $row)
& $row['attr_value'] = str_replace("\n", '
', $row['attr_value']);
& if ($row['attr_type'] == 0)
& & & $group =
(isset($groups[$row['attr_group']])) ? $groups[$row['attr_group']]
: $GLOBALS['_LANG']['goods_attr'];
//$arr['pro'][$group][$row['attr_id']]['name'] &=
$row['attr_name'];
$arr['pro'][$row['attr_id']]['name'] &=
$row['attr_name'];
$arr['pro'][$row['attr_id']]['value'] = $row['attr_value'];
$arr['spe'][$row['attr_id']]['attr_type'] = $row['attr_type'];
$arr['spe'][$row['attr_id']]['name'] &
& = $row['attr_name'];
$arr['spe'][$row['attr_id']]['values'][] = array(
& 'label' & &
& &=& $row['attr_value'],
& 'price' & &
& &=& $row['attr_price'],
'img' & & &
$row['attr_img'],
& 'format_price' =&
price_format(abs($row['attr_price']), false),
& 'id' & &
$row['goods_attr_id']);
& if ($row['is_linked'] == 1)
$arr['lnk'][$row['attr_id']]['name'] &=
$row['attr_name'];
$arr['lnk'][$row['attr_id']]['value'] = $row['attr_value'];
&&$arr['lnk'][$row['attr_id']]['img']
& = $row['attr_img'];
& & return $
{$spec.name}:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。ecshop想实现点击颜色后左边与之相关联的转换_百度知道
提问者采纳
兴品软件园有实现的教程
提问者评价
采纳率100%
其他类似问题
为您推荐:
其他2条回答
你好,这个是属性图片添加的功能,可以考虑找正规二次开发商合作,模板堂已经做好这样的功能了哦
这个需要二次开发的。免费的代码是没有的哦。
ecshop的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁关于PB开发的界面问题!不知大家都用什么方法美化界面。按钮的底色颜色怎样才能变啊?怎样才能在PictureButton最左边放一幅小小的图标啊?
[问题点数:30分,结帖人wind1825]
关于PB开发的界面问题!不知大家都用什么方法美化界面。按钮的底色颜色怎样才能变啊?怎样才能在PictureButton最左边放一幅小小的图标啊?
[问题点数:30分,结帖人wind1825]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
本帖子已过去太久远了,不再提供回复功能。}

我要回帖

更多关于 ecshop 文章缩略图 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信