技术资讯
dede:sql 调用flag att文档属性 翻页
2014-07-25 12:40:12
dede:sql标签分页 dede:sql 调用flag/att文档属性 翻页,加拿大预测网-在线预测:青岛网站建设中有时候需要在页面上通过sql语句调用其他数据库或者其他表的数据,例如在当前列表页调用一个特定文档属性的文章列表,再加上翻页,效果就不好处理了,需要对arc.listview.class.php进行改造,方法在这篇文章有描述 加拿大预测网-在线预测:DEDE{dede:sql}标签如何分页 ,下文最后会在描述一遍,改造完着文件后,就可以这样调用了。
{dede:listsql pagesize='1' sql="select a.id as aid, a.description as description, t.id as tid,typeid,senddate,title,litpic,ismake,arcrank,💝namerule,typedir From ltd_archives a, ltd_arctype t where a.typeid = t.id and FIND_IN_SET('f', flag)>0" }
<li><a href="[field:array runphp='yes']@me=꧟GetFileUrl(@me['aid'],@me['typeid'],@me['senddate'],@me['title'],@me['ismake'],@me['description'],@me['arcrank'],@ꦑme['namerule'],@me['typedir'],@me['money']);[/field:array]"><img src="[field:litꦓpic/]" width="304" he♛ight="158" /><h4>[field:title/]</h4>
<h5>[field:senddate function='strftime("%Y-%m-%d",@me)'/]</h5>
<p>[field:description/]...</p></a>
</li>
{/dede:listsql}
<div class="page">
<!--分页-->
{dede:pagelist listsize='1' listitem='pre pageno next'/}
</div>
arc.listview.class.php进行改造,方法:
找到:
if(!is_object($ctag))
{
$ctag = $this->dtp->GetTag("list");
}
这一段,在其后添加如下代码:
if(!is_object($ctag))
{
$ctag = $this->dtp->GetTag("listsql");
if (is_object($ctag))
{
$cquery = $ctag->GetAtt("sql");
$cquery = preg_replace("/SELECT(.*?)FROM/is", " SELECT count(*) as dd FROM ", $cquery);
$cquery = preg_replace("/ORDER(.*?)SC/is", "", $cquery);
$row = $this->dsql->GetOne($cquery);
if(is_array($row))
{
$this->TotalResult = $row['dd'];
}
else
{
$this->TotalResult = 0;
}
}
}
//end
然后找到:
if($ctag->GetName()=="list")
{
$limitstart = ($this->PageNo-1) * $this->PageSize;
$row = $this->PageSize;
if(trim($ctag->GetInnerText())=="")
{
$InnerText = GetSysTemplets("list_fulllist.htm");
}
else
{
$InnerText = trim($ctag->GetInnerText());
}
$this->dtp->Assign($tagid,
$this->GetArcList(
$limitstart,
$row,
$ctag->GetAtt("col"),
$ctag->GetAtt("titlelen"),
$ctag->GetAtt("infolen"),
$ctag->GetAtt("imgwidth"),
$ctag->GetAtt("imgheight"),
$ctag->GetAtt("listtype"),
$ctag->GetAtt("orderby"),
$InnerText,
$ctag->GetAtt("tablewidth"),
$ismake,
$ctag->GetAtt("orderway")
)
);
}
这一段,在其后添加如下代码:
else if($ctag->GetName()=="listsql")
{
$limitstart = ($this->PageNo-1) * $this->PageSize;
$row = $this->PageSize;
if(trim($ctag->GetInnerText())=="")
{
$InnerText = GetSysTemplets("list_fulllist.htm");
}
else
{
$InnerText = trim($ctag->GetInnerText());
}
$this->dtp->Assign($tagid,
$this->GetSqlList(
$limitstart,
$row,
$ctag->GetAtt("sql"),
$InnerText
)
);
}
//end
最后找到function GetArcLi🍌st这个方法,在其后添加一个可以通过꧃传入sql参数获取指定数据源的方法,代码如下:
function GetSqlList($limitstart = 0, $row = 10, $sql = '', $innertext){
global $cfg_list_son;
$innertext = trim($innertext);
if ($innertext == '') {
$innertext = GetSysTemplets('list_fulllist.htm');
}
//处理SQL语句
$limitStr = " LIMIT {$limitstart},{$row}";
$this->dsql->SetQuery($sql . $limitStr);
$this->dsql->Execute('al');
$t2 = ExecTime();
//echo $t2-$t1;
$sqllist = '';
$this->dtp2->LoadSource($innertext);
$GLOBALS['autoindex'] = 0;
//获取字段
while($row = $this->dsql->GetArray("al")) {
$GLOBALS['autoindex']++;
if(is_array($this->dtp2->CTags))
{
foreach($this->dtp2->CTags as $k=>$ctag)
{
if($ctag->GetName()=='array')
{
//传递整个数组,在runphp模式中有特殊作用
$this->dtp2->Assign($k,$row);
}
else
{
if(isset($row[$ctag->GetName()]))
{
$this->dtp2->Assign($k,$row[$ctag->GetName()]);
}
else
{
$this->dtp2->Assign($k,'');
}
}
}
}
$sqllist .= $this->dtp2->GetResult();
}//while
$t3 = ExecTime();
//echo ($t3-$t2);
$this->dsql->FreeResult('al');
return $sqllist;
}
//end
近期更新
- [2023-07-26 14:17:28] 加拿大预测网-在线预测:为品牌赋能,海外官网品牌数字化
- [2023-05-06 10:32:26] 🌊加拿大预测网-在线预测:青岛网站建设公司,高端网站定制,一站式网站服务——力图数字科技
- [2023-04-27 13:47:54] 加拿大预测网-在线预测:高端定制网站建设——从满足预期到走向卓越
- [2023-04-11 09:17:49] 加拿大预测网-在线预测:H5页面设计开发——移动端传播利器
- [2022-11-16 10:11:43] 加拿大预测网-在线预测:windows2012程序在哪
- [2022-04-14 11:01:47] 加拿大预测网-在线预测:力图数字科技配套网站服务支持
- [2021-05-18 10:14:11] 加拿大预测网-在线预测:青岛网站建设的流程
- [2021-04-29 10:14:38] 加拿大预测网-在线预测:企业定制化官网建设项目
- [2021-03-05 10:34:45] 加拿大预测网-在线预测:移动互联时代房地产行业的微信小程序解决方案
- [2021-01-22 17:29:38] 加拿大预测网-在线预测:微信小程序有哪些优势?为什么要开发微信小程序?
- [2021-01-08 17:28:04] 加拿大预测网-在线预测:网站建设最容易忽略的人性化设计
- [2020-12-16 16:55:32] 加拿大预测网-在线预测:建设一个常规的公司网站建设成本大概是多少?
延伸阅读
- [2015-01-24 09:57:47] 加拿大预测网-在线预测:网站更换如何保护好我们已有的排名?
- [2019-05-14 11:09:21] 加拿大预测网-在线预测:青岛网站设计公司哪家好
- [2015-06-01 21:45:01] 加拿大预测网-在线预测:分享一个多个变量的sql语句
- [2014-12-18 09:16:13] 加拿大预测网-在线预测:网站设计可用性的重要之处
- [2011-11-05 23:02:49] 加拿大预测网-在线预测:让网站外链在你睡着的时候也能自动增加的方法
- [2018-06-04 20:53:05] 加拿大预测网-在线预测:ueditor源代码模式居左
- [2015-02-16 10:48:17] 加拿大预测网-在线预测:关键词网页应该放到什么位置?
- [2011-11-11 12:22:51] 加拿大预测网-在线预测:修改文章正文 影响收录
- [2011-11-17 12:09:39] 加拿大预测网-在线预测:谷歌安卓与苹果iOS系统用户界面风格比较及技术分析
- [2014-10-28 09:17:05] 加拿大预测网-在线预测:Wordpress主题欣赏展示
- [2013-01-26 15:07:29] 加拿大预测网-在线预测:dede图集大图绝对路径
- [2012-06-26 09:49:05] 加拿大预测网-在线预测:网页设计中的图层叠加混合模式
解决方案
加拿大预测网-在线预测: 轮胎行业网站设计解决方案 加拿大预测网-在线预测: 机械行业网站设计解决方案 加拿大预测网-在线预测: 房地产行业网站设计解决方案 加拿大预测网-在线预测: 科技企业网站设计解决方案 加拿大预测网-在线预测: 电子家电网站设计解决方案 加拿大预测网-在线预测: 食品行业网站设计解决方案 加拿大预测网-在线预测: 集团公司网站设计解决方案 加拿大预测网-在线预测: 企事业单位网站设计解决方案 加拿大预测网-在线预测: 外贸行业网站设计解决方案 加拿大预测网-在线预测: 健身运动网站设计解决方案 加拿大预测网-在线预测: 美容与化妆品网站设计解决方案 加拿大预测网-在线预测: 建筑设计行业网站设计解决方案 加拿大预测网-在线预测: 物流行业网站设计解决方案