织梦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的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}
修改文件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']." ".$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>
最近在数据采集过程中遇到aspx __doPostBack数据加载方式,利用火车头(免费版)或php采集程序无有效方法采集,于是手动编写chrome浏览器插件自动点击“下一页”翻页抓取网址数据,继而用火车头采集数据。
使用PHP自带的一个函数:array_column() ,该函数的作用是返回输入数组中某个单一列的值。
$firms = M('lawfirm')->where('status=1')->field('id')->select();
$firmids = array_column($firms, 'id');
$who = implode(',', $firmids);
或是通过foreach进行拼装。
不能将富文本对象转换为数组。一般我们在上传导Excel的时候会出现此问题,问题的原因是Excel表格中有富文本对象。
解决方法1: $student['actual_residence']=(string)$objPHPExcel->getActiveSheet()->getCell("M".$i)->getValue();
原理:将富文本对象转换为string类型。
解决方法2:
其实在PHPExcel中已经有转换的方法写好了,直接调用即可。 $objPHPExcel->getActiveSheet()->getCell("M".$i)->getValue()->__toString();
当然,最简单的方式那就直接把excel表格格式化样式即可。
DHC是一款使用chrome模拟REST客户端向服务器发送测试数据的谷歌浏览器插件。
在web开发中,服务器端和客户端的开发和测试必不可少,但是测试的工作往往需要服务器端完成之后,客户端才能进行测试,这无疑延后了测试流程,导致服务器端开发完成后,无法进行充分的数据测试,很容易造成服务器端和客户端开发完成后出现不协调的情况,而今天给大家推荐的这款HTTP工具,可以提前对服务器端代码进行测试。
DHC是一款可以帮助用户使用chrome插件模拟HTTP客户端发送测试数据到服务器的谷歌浏览器插件,在chrome中安装了DHC插件以后,就可在服务器端代码初步完成的时候,使用DHC进行数据测试,以便更早地了解到程序的BUG和需求。DHC插件的使用方式也非常简单,只需要输入服务器端的地址,以及发送的方式和数据内容,就可以向服务器端发送指定的数据,并获取服务器端的返回值。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>GO</title>
</head>
<body>
<h1>WAITING ...</h1>
</body>
<script>
window.onload=function(){
getLocation();
go();
}
function getLocation(){
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(showPosition);
}else{
x.innerHTML="Geolocation is not supported by this browser.";
}
}
function showPosition(position){
// alert(position.coords.latitude+","+position.coords.longitude);
}
function go(){
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(comeOn);
}else{
x.innerHTML="Geolocation is not supported by this browser.";
}
}
function comeOn(position){
window.location.href="http://api.map.baidu.com/direction?origin=latlng:"+position.coords.latitude+","+position.coords.longitude+"|name:我的位置&destination=风筝博物馆&mode=driving®ion=潍坊&output=html&src=zhinizhiwo.com|icecry";
}
</script>
</html>
最近计划入坑Laravel,无奈php>5.6,现用wamp为5.5.12,升级。
1.下载php5.6.30 VC11 x64 Thread Safe,http://windows.php.net/download/
2.wamp/bin/php目录创建php5.6.30目录并复制文件
3.复制php5.5.12下的php.ini、phpForApache.ini、wampserver.conf至php5.6.30目录 下,并将php.ini、phpForApache.ini中的5.5.12全部替换成5.6.30
注:也可复制php.ini-development文件,修改后保存为php.ini及phpForApache.ini
4.删除wamp\bin\apache\apache2.4.9\bin下的php.ini文件
5.wamp中重启服务,此时php版本只显示5.5.12,点击重启,便可出现5.6.30版本,选择。
备注:php5.6以上版本,curl拓展开启问题
php.ini中 ;extension=php_curl.dll 前的;已经去除,但仍提示curl未开启
解决办法:将php安装目录下的libssh2.dll复制到apache的bin目录,并重新启动apache