• 欢迎访问苗景云的博客

解决的办法,在phpcms\libs\functions\extention.func.php(自定义函数文件)中定义一个方法

/**
 * 获取选项的格式化输出
 * @param str $field 字段名称 必须
 * @param int $value 字段值 必须
 * @param int $modelid 模型ID 必须
 * 2014-09-28 by awen
*/
function get_box($field, $value,$modelid) {
        $fields = getcache('model_field_'.$modelid,'model');
        extract(string2array($fields[$field]['setting']));
        if($outputtype) {
                return $value;
        } else {
                $options = explode("\n",$fields[$field]['options']);
                foreach($options as $_k) {
                        $v = explode("|",$_k);
                        $k = trim($v[1]);
                        $option[$k] = $v[0];
                }
                $string = '';
                switch($fields[$field]['boxtype']) {
                        case 'radio':
                                $string = $option[$value];
                        break;

                        case 'checkbox':
                                $value_arr = explode(',',$value);
                                foreach($value_arr as $_v) {
                                        if($_v) $string .= $option[$_v].' ';
                                }
                        break;

                        case 'select':
                                $string = $option[$value];
                        break;

                        case 'multiple':
                                $value_arr = explode(',',$value);
                                foreach($value_arr as $_v) {
                                        if($_v) $string .= $option[$_v].' ';
                                }
                        break;
                }
                return $string;
        }
}

这个是照内容输出页面的原理弄出来的,是系统的实现方式,安全可靠,只是把原来的、号分隔改成了空格,也可以加一个标签之类的,可以自己改。
前台使用
第一个是你的字段名称,第二个是你字段的值,就是输出的1、2、3,第三个是你所使用的模型iD
如楼盘特色字段名为‘lpts’,字段值为$r[lpts]这是loop循环得到的变量也可以是一个指定的你定义的值,第三个15是楼盘模型的ID
{get_box('lpts',$r[lpts],15)}
效果如下
 

发布:苗景云 | 查看全文 | 浏览(2237) | 分类:IT技术&设计 | 评论(0) | 2016年12月19日

首先我们注意的一个问题是,作为循环,if判断的条件不能是“==”,因为是“==”的话当走到5之后就永远不会符合条件了,所以第五个后面的就不会被显示了,我们可以用求余作为条件式来作为循环条件,例如第二个:

发布:苗景云 | 查看全文 | 浏览(2154) | 分类:IT技术&设计 | 评论(0) | 2016年11月23日

比如,我想在文章内容页,只显示年月日,不显示时分秒,按列表页用date函数会显示1970,找了很多方法,

后面看到化碟版主的,解决了,所以这里记录一下,直接用 $rs[inputtime] 就是输出了时间戳,然后用date来处理.

{date('M-d, Y',$rs[inputtime])}

另,还发现,date里,写M是显示英文的日期,m是数字。呵呵

发布:苗景云 | 查看全文 | 浏览(2026) | 分类:IT技术&设计 | 评论(0) | 2016年11月20日

phpcms默认的输出序号是{php $num++},然后用{$num}调用,但是如果自定义多图字段输出的值不是从1开始。解决方法如下


{loop $subdetail $pic_k $v}

<img src="{$v[url]}" alt="{$v[alt]}" class="sub0{$n}">

发布:苗景云 | 查看全文 | 浏览(1716) | 分类:IT技术&设计 | 评论(0) | 2016年11月20日

列表页:{trim($r[字段],' 、')}


内容页:{trim($字段,' 、')}

发布:苗景云 | 查看全文 | 浏览(1470) | 分类:IT技术&设计 | 评论(0) | 2016年11月20日

PHPCMS 判断列表分页是否第一页的代码


{if $page==1}......{/if}

发布:苗景云 | 查看全文 | 浏览(2062) | 分类:IT技术&设计 | 评论(0) | 2016年11月17日

<style type="text/css">

*{margin:0;padding:0;list-style-type:none;}

a,img{border:0;text-decoration:none;}

body{font:12px/180% Arial, Helvetica, sans-serif, "新宋体";}

table{empty-cells:show;border-collapse:collapse;border-spacing:0;}

发布:苗景云 | 查看全文 | 浏览(1559) | 分类:IT技术&设计 | 评论(0) | 2016年11月08日

<!doctype html>  

<html>  

 <head>  

 <meta http-equiv="content-type" content="text/html;charset=UTF-8"/>  

  <title>复选框全选、全不选、反选、必选一个</title>  

发布:苗景云 | 查看全文 | 浏览(1521) | 分类:IT技术&设计 | 评论(0) | 2016年11月07日
首先必须确保你是从这里下的留言版插件留言板 UTF-8 2.5版本.rar后台模块中安装好以后打开模版目录:phpcms/templates/default/guestbook/异步提交和读取你可以选择在index、register、list_type三个模版里做都行,看你自己的需要。这里就删繁就简了。我是直接在 index 模版文件下做的,所以添加留言板时的地址为:http://localhost/index.php?m=guestbook&c=index在 register 模版文件
发布:苗景云 | 查看全文 | 浏览(52084) | 分类:IT技术&设计 | 评论(0) | 2016年11月05日

废话不多说,直接上DEMO下载地址:http://download.csdn.net/detail/cometwo/9602499

参考链接:http://www.dowebok.com/134.html


发布:苗景云 | 查看全文 | 浏览(2303) | 分类:IT技术&设计 | 评论(0) | 2016年10月11日
PHPCMS自带组图功能无排序功能,特别是需要对图片和说明排序时很不方便,通过此方法可实现组图排序。工具/原料PHPCMS V9   dreamweaver方法/步骤1 新增上下移动的按钮用dreamweaver打开文件form.inc.php,文件位置:phpcms/modules/content/fields/images/form.inc.php在第八行的".L('remove_out', '', 'content
发布:苗景云 | 查看全文 | 浏览(1837) | 分类:IT技术&设计 | 评论(0) | 2016年10月11日

排名规则

发布:苗景云 | 查看全文 | 浏览(1769) | 分类:网络营销&电子商务 | 评论(0) | 2016年10月09日

首页的推荐商品包括热销推荐和促销三个文件

发布:苗景云 | 查看全文 | 浏览(1838) | 分类:IT技术&设计 | 评论(0) | 2016年09月23日

1、打开mobile/index.php,添加以下代码


//获取商品分类 

$pcat_array = get_categories_tree();

foreach ($pcat_array as $key => $pcat_data)

{

    $pcat_array[$key]['goods_list'] = get_parent_category_goods($pcat_data['id']);

发布:苗景云 | 查看全文 | 浏览(3276) | 分类:管理&经济 | 评论(0) | 2016年09月23日
1.在sq执行语句
 
ALTER TABLE `ecs_goods` ADD `sales_volume_base` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'  
 
INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('7','show_goods_sales', 'select', '1,0', '', '1', '1');  
 
INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('3', 'show_sales_type', 'select', '1,0', '', '1', '1');  
注意:如果你的数据表前缀不是‘ecs_’ 请自行修改
 
2./admin/includes/lib_goods.php中
 
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .  
            " (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ".  
            " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
            " ORDER BY $filter[sort_by] $filter[sort_order] ".  
            " LIMIT " . $filter['start'] . ",$filter[page_size]";  
修改为
 
        $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, sales_volume_base, " .   
                    " (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ".  
                    " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .  
                    " ORDER BY $filter[sort_by] $filter[sort_order] ".  
                    " LIMIT " . $filter['start'] . ",$filter[page_size]";  
 
3./admin/templates/goods_list.htm,在
 
{if $use_storage}  
<th><a href="javascript:listTable.sort('goods_number'); ">{$lang.goods_number}</a>{$sort_goods_number}</th>  
{/if}  
后,添加
 
<th><a href="javascript:listTable.sort('sales_volume_base'); ">{$lang.sales_volume_base}</a>{$sort_sales_volume_base}</th>  
 
{if $use_storage}  
<td align="right"><span onclick="listTable.edit(this, 'edit_goods_number', {$goods.goods_id})">{$goods.goods_number}</span></td>  
{/if}  
后,添加
 
<td align="center"><span onclick="listTable.edit(this, 'edit_sales_volume_base', {$goods.goods_id})">{$goods.sales_volume_base}</span></td>  
 
4./admin/goods.php,在
 
/** 
 * 列表链接 
 * @param   bool    $is_add         是否添加(插入) 
 * @param   string  $extension_code 虚拟商品扩展代码,实体商品为空 
 * @return  array('href' => $href, 'text' => $text) 
 */  
function list_link($is_add = true, $extension_code = '')  
前,添加
 
/*------------------------------------------------------ */  
//-- 修改商品虚拟销量  
/*------------------------------------------------------ */  
elseif ($_REQUEST['act'] == 'edit_sales_volume_base')  
{  
    check_authz_json('goods_manage');  
  
    $goods_id = intval($_POST['id']);  
    $sales_volume_base = json_str_iconv(trim($_POST['val']));  
  
    if ($exc->edit("sales_volume_base = '$sales_volume_base', last_update=" .gmtime(), $goods_id))  
    {  
        clear_cache_files();  
        make_json_result(stripslashes($sales_volume_base));  
    }  
}  
5.goods.php,在
 
$smarty->assign('categories',         get_categories_tree($goods['cat_id']));  // 分类树  
后,添加
 
$smarty->assign('sales_count',        get_sales_count($goods_id));  
在末尾添加
 
/* 商品累计销量带自定义_新增加 */  
function get_sales_count($goods_id)  
{  
    /* 查询该商品的自定义销量 */  
    $sales_base = $GLOBALS['db']->getOne('SELECT sales_volume_base FROM '.$GLOBALS['ecs']->table('goods').' WHERE goods_id = '.$goods_id);  
    /* 查询该商品的实际销量 */  
    $sql = 'SELECT IFNULL(SUM(g.goods_number), 0) ' .  
        'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o, ' .  
            $GLOBALS['ecs']->table('order_goods') . ' AS g ' .  
        "WHERE o.order_id = g.order_id " .  
        "AND o.order_status " . db_create_in(array(OS_CONFIRMED, OS_SPLITED)) .  
        "AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) .  
        " AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) .  
        " AND g.goods_id = '$goods_id'";  
    $sales_count = $GLOBALS['db']->getOne($sql);  
    /* 商品累计销量默认显示方式 */  
    if ($GLOBALS['_CFG']['show_sales_type'])  
    {  
        $row['sales_volume_total'] =  $sales_count; //实际销量  
    }  
    else  
    {  
        $row['sales_volume_total'] =  $sales_base + $sales_count; //自定义销量+实际销量  
    }  
    return ($row['sales_volume_total']);  
}  
6.在/languages/zh_cn/admin/shop_config.php,中
 
/languages/zh_cn/admin/shop_config.php  
下,添加
 
$_LANG['cfg_name']['show_goods_sales'] = '是否显示商品累计销量';  
$_LANG['cfg_range']['show_goods_sales']['1'] = '显示';  
$_LANG['cfg_range']['show_goods_sales']['0'] = '不显示';  
$_LANG['cfg_name']['show_sales_type'] = '商品累计销量默认显示方式';  
$_LANG['cfg_range']['show_sales_type'][1] = '真实显示';  
$_LANG['cfg_range']['show_sales_type'][0] = '虚拟显示';  
 
7./languages/zh_cn/admin/goods.php,中
 
$_LANG['goods_sn_exists'] = '您输入的货号已存在,请换一个';  
后,添加
 
$_LANG['sales_volume_base'] = '虚拟销量';  
 
8./languages/zh_cn/common.php,中
 
$_LANG['divided_into'] = '分成规则';  
后,添加
 
$_LANG['sales_volume_total'] = '累计销量:';   
$_LANG['pcs'] = '件';  
 
9./themes/default/goods.dwt,在
 
<img src="images/stars{$goods.comment_rank}.gif" alt="comment rank {$goods.comment_rank}" />  
 </dd>  
后,添加
 
{if $cfg.show_goods_sales}  
<dd style="width:48%; padding-left:7px;">  
<strong>{$lang.sales_volume_total}</strong>  
<font class="shop">{$sales_count}{if $goods.measure_unit}{$goods.measure_unit}{else}{$lang.pcs}{/if}</font>  
</dd>  
{/if}  
OK,完成!


发布:苗景云 | 查看全文 | 浏览(1916) | 分类:IT技术&设计 | 评论(0) | 2016年09月22日

 在ECSHOP首页显示商品总数和本月更新数  
1)、首先修改 /index.php  找到   assign_dynamic('index'); 
在它后边添加一些代码   
$sql="select count(*) as goods_all from ". $ecs->table('goods'); //商品总数
$smarty->assign('goodsnum_all',$db->getOne($sql));  
$time_month=mktime(0,0,0,date('m')-1,1,date('Y'));   
$sql="select count(*) as goods_month from ". $ecs->table('goods') ." where last_update >= " . $time_month; //本月更新数   
$smarty->assign('goodsnum_month',$db->getOne($sql));
2)、打开首页模板文件 index.dwt,在合适的地方调用,调用代码为  本商城共有商品 {$goodsnum_all} 件,本月更新 {$goodsnum_month} 件

发布:苗景云 | 查看全文 | 浏览(1484) | 分类:IT技术&设计 | 评论(0) | 2016年09月22日

 

管理员密码忘记,通过重新安装的密码更换数据库,或者通过md5加密密文替换数据库,都一一失败,这个问题困扰了很多朋友。

发布:苗景云 | 查看全文 | 浏览(1693) | 分类:IT技术&设计 | 评论(0) | 2016年09月21日

 phpcms 图片模型组图列表获取图片尺寸需要用到getimagesize函数,不废话,直接看代码:

 

{loop $pictureurls $pic_k $r}
    {php $info = getimagesize($r[url])}
     <a href="{thumb($r[url], 700, 700, 0)}" data-author="{$r[alt]}" data-size="{$info[0]}x{$info[1]}" data-med="{thumb($r[url], 700, 700, 0)}" data-med-size="{$info[0]}x{$info[1]}"><img src="{thumb($r[url], 700, 700, 0)}" width="160" /><span>{$r[alt]}</span></a>
     {/loop}

发布:苗景云 | 查看全文 | 浏览(1691) | 分类:IT技术&设计 | 评论(0) | 2016年07月27日
« 之后的文章苗景云的博客
<< 向左走,向右走 >>
更早的文章 »