叶测试 发布的文章

织梦dedeCMS让{dede:list}标签支持weight权重排序

修改\include\arc.listview.class.php在文件第727行处添加按weight排序判断代码:

else if($orderby=="weight") {
    $ordersql = "ORDER BY arc.weight $orderWay";
}

第778行处找到此段代码(如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)):
if(preg_match('/hot|click|lastpost|weight/', $orderby))

标签调用:
{dede:list isweight='Y' orderby='weight' orderway='asc'}

Flex 布局基础

Flex是Flexible Box的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性。任何一个容器都可以指定为Flex布局。Webkit内核的浏览器,必须加上-webkit前缀。

bg2015071003.jpg

- 阅读剩余部分 -

织梦dedecms循环判断是否为第一个

判断是否为第一个
dedecms的arclist循环中,判断如果是第一个li,则添加固定的css,否则不加。

{dede:arclist row=4  flag='p'}
 <li [field:global name=autoindex runphp="yes"](@me==1)? @me="class=on":@me="";[/field:global]>[field:global.autoindex/]</li>
{/dede:arclist}

- 阅读剩余部分 -

dedecms织梦手机网站添加上一页/下一页的翻页功能

修改文件include/arc.archives.class.php文件,function GetPreNext($gtype='')函数修改为:

function GetPreNext($gtype='')
    {
        $rs = '';
        if(count($this->PreNext)<2)
        {
            $aid = $this->ArcID;
            $preR =  $this->dsql->GetOne("Select id From `#@__arctiny` where id<$aid And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id desc");
            $nextR = $this->dsql->GetOne("Select id From `#@__arctiny` where id>$aid And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id asc");
            $next = (is_array($nextR) ? " where arc.id={$nextR['id']} " : ' where 1>2 ');
            $pre = (is_array($preR) ? " where arc.id={$preR['id']} " : ' where 1>2 ');
            $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
                        t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
                        from `#@__archives` arc left join #@__arctype t on arc.typeid=t.id  ";
            $nextRow = $this->dsql->GetOne($query.$next);
            $preRow = $this->dsql->GetOne($query.$pre);
            
            
            
    
            if(is_array($preRow))
            {
                $mlink = GetFileUrl($preRow['id'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],
                $preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],$preRow['moresite'],$preRow['siteurl'],$preRow['sitepath']);
                $mobile_mlink = "/m/view.php?aid=".$preRow['id'];
                $this->PreNext['pre'] = "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
                $this->PreNext['mobile_pre'] = "上一篇:<a href='$mobile_mlink'>{$preRow['title']}</a> ";
                $this->PreNext['preimg'] = "<a href='$mlink'><img src=\"{$preRow['litpic']}\" alt=\"{$preRow['title']}\"/></a> "; 
            }
            else
            {
                $this->PreNext['pre'] = "上一篇:没有了 ";
                $this->PreNext['mobile_pre'] = "上一篇:没有了 ";
                $this->PreNext['preimg'] ="<img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有上一图集了!\"/>";
            }
            if(is_array($nextRow))
            {
                $mlink = GetFileUrl($nextRow['id'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],
                $nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],$nextRow['filename'],$nextRow['moresite'],$nextRow['siteurl'],$nextRow['sitepath']);                
                $mobile_mlink = "/m/view.php?aid=".$nextRow['id'];
                $this->PreNext['next'] = "下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
                $this->PreNext['mobile_next'] = "下一篇:<a href='$mobile_mlink'>{$nextRow['title']}</a> ";
                $this->PreNext['nextimg'] = "<a href='$mlink'><img src=\"{$nextRow['litpic']}\" alt=\"{$nextRow['title']}\"/></a> ";
            }
            else
            {
                $this->PreNext['next'] = "下一篇:没有了 ";
                $this->PreNext['mobile_next'] = "下一篇:没有了 ";
                $this->PreNext['nextimg'] ="<a href='javascript:void(0)' alt=\"\"><img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有下一图集了!\"/></a>";
            }
        }
        if($gtype=='pre')
        {
            $rs =  $this->PreNext['pre'];
        }
        else if($gtype=='preimg'){
            
            $rs =  $this->PreNext['preimg'];
        }        
        else if($gtype=='mobile_pre'){
            
            $rs =  $this->PreNext['mobile_pre'];
        }
        else if($gtype=='next')
        {
            $rs =  $this->PreNext['next'];
        }        
        else if($gtype=='mobile_next')
        {
            $rs =  $this->PreNext['mobile_next'];
        }
        else if($gtype=='nextimg'){
            
            $rs =  $this->PreNext['nextimg'];
        }
        else
        {
            $rs =  $this->PreNext['pre']." &nbsp; ".$this->PreNext['next'];
        }
        return $rs;
    }

在手机网站详情页模板内,将调用上一页、下一页标签插入。

<ul class="am-pagination blog-pagination">
      <li>{dede:prenext get='mobile_pre'/}</li>
      <div style="clear:both;"></div>
      <li>{dede:prenext get='mobile_next'/}</li>
</ul>

二维数组中取某一相同字段的值进行,拼接字符串

使用PHP自带的一个函数:array_column() ,该函数的作用是返回输入数组中某个单一列的值。

$firms = M('lawfirm')->where('status=1')->field('id')->select();
$firmids = array_column($firms, 'id');
$who = implode(',', $firmids);

或是通过foreach进行拼装。

Cannot use object of type PHPExcel_RichText as array

不能将富文本对象转换为数组。一般我们在上传导Excel的时候会出现此问题,问题的原因是Excel表格中有富文本对象。

解决方法1:
$student['actual_residence']=(string)$objPHPExcel->getActiveSheet()->getCell("M".$i)->getValue();
原理:将富文本对象转换为string类型。

解决方法2:
其实在PHPExcel中已经有转换的方法写好了,直接调用即可。
$objPHPExcel->getActiveSheet()->getCell("M".$i)->getValue()->__toString();

当然,最简单的方式那就直接把excel表格格式化样式即可。