需求说明
有时我们需要通过SQL标签调用栏目的介绍(classbasicinfo)及自定义内容(classdefinecontent),他们的结构是用这种方式存储的"a|||b|||c",这个时间,如果我们需要其中的一项,就需要split函数,而科汛没有提供,为此特意二次开发
代码修改:Kesion.Label.SQLCls.asp
示例:{$SQLReplace({$Field(ClassDefineContent,Text,0,0,2,)},||||,0)}
参说说明:参数1是为要拆分的内容,参数2是拆分的分割符,参数3是取第几位,注意是以0开始的
找到大约350行,增加以下红色部分
End If
KS_RS_Obj.MoveNext
Next
GetCirLabelContent=MySplitField(GetCirLabelContent)
End Function
Function MySplitField(lpFieldValue)
Dim regEx, Matches, Match
Dim FieldParam,FieldParamArr,mytempValue,mytempNum,mytarget,templpFieldValue
Set regEx = New RegExp
regEx.Pattern = "{\$SQLReplace\([^{\$}]*}"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(lpFieldValue)
For Each Match In Matches
FieldParam = Replace(Replace(Match.Value,"{$SQLReplace(",""),")}","")
FieldParamArr = Split(FieldParam,",")
mytempValue=split(replace(Replace(KS.LoseHtml(KS.HtmlCode(FieldParamArr(0)))," ","")," ",""),trim(FieldParamArr(1)))
if ubound(mytempValue)>=cint(FieldParamArr(2)) then lpFieldValue=Replace(lpFieldValue,Match.Value,mytempValue(FieldParamArr(2)))
Next
MySplitField=lpFieldValue
End Function
调用说明:
SQL语句:select top {$Param(0)} classid,id,foldername,ClassDefineContent from ks_class where tn='{$Param(1)}' and topflag=1 order by folderorder asc
循环部分:<dl>[loop={$Param(0)}]<dt>{$SQLReplace({$Field(ClassDefineContent,Text,0,0,2,)},||||,0)}【<a href="{$Field(id,GetInfoUrl,100,1)}">{$Field(foldername,Text,0,...,0,)}</a>】</dt><dd>{SQL_疾病导航内部(10,{$Field(id,GetInfoUrl,100,2)})}</dd>[/loop]</dl>
演示:http://www.shdazhongbanjia.com/html/list_649.html