科汛的栏目信息是放在一个字段里的,我们如何获取某一项内容?
如何实现取英文首字母特殊加效果?
别着急,本人刚开发出一个新标签可以帮你解决以上问题:
截取标签{$INTERCEPTION(aaa[]b[]c)}
以{$REPLACE(待替换的字符串||关键字1,替换后的字1|关键字2,替换后的字2)}
仿造截取标签{$INTERCEPTION(字符串集合[]内容所在位数[]显示的字符数)}
废话不多说,创建方法:
修改ks_cls\Kesion.Label.SQLCls.asp
需要改三处:
第一处:
For i=0 to objNode.ChildNodes.length-1
set objAtr=objNode.ChildNodes.item(i)
Str=Replace(Replace(Replace(Replace(Replace(Replace(Replace(objAtr.Attributes.item(2).Text,"{$Field","{#Field"),"{$AutoID}","{#AutoID}"),"{$IF","{#IF"),"{$Param","{#Param"),"{$GetItemUrl}","{#GetItemUrl}"),"{$REPLACE","{#REPLACE"),"{$INTERCEPTION","{#INTERCEPTION") '避免Field字段被替换掉,先转为#
Str=Rcls.ReplaceGeneralLabelContent(Str)
Str=Replace(Replace(Replace(Replace(Replace(Replace(Str,"{#Field","{$Field"),"{#AutoID}","{$AutoID}"),"{#IF","{$IF"),"{#Param","{$Param"),"{#REPLACE","{$REPLACE"),"{#INTERCEPTION","{$INTERCEPTION")
objAtr.Attributes.item(2).Text=Str
第二处:
End Function
'截取字段 {$INTERCEPTION(aaa[]b[]c)}
'aaa为要截取的集合字符串; b为以“||||”截取后取第几位(以0开始); c为显示字符串长度,为0时为不截取; 中间用“[]”分开b、c为整数
Function ReplaceCondition2(byval str)
Dim regEx, Matches, Match, TempStr,Bool
Dim FieldParam,FieldParamArr,ReturnFieldValue,I,FieldParamArr1,FieldParamArr2,FieldParamArr3
on error resume next
Set regEx = New RegExp
regEx.Pattern = "{\$INTERCEPTION\([^{\$}]*}"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(str)
TempStr=str
For Each Match In Matches
FieldParam = Replace(Replace(Match.Value,"{$INTERCEPTION(",""),")}","")
FieldParamArr = Split(FieldParam,"[]")
FieldParamArr2=Split(FieldParamArr(0),"||||")
if FieldParamArr(2)=0 then
ReturnFieldValue=FieldParamArr2(FieldParamArr(1))
else
ReturnFieldValue=left(FieldParamArr2(FieldParamArr(1)),FieldParamArr(2))
end if
if err then
err.clear
else
TempStr=Replace(TempStr,"{$INTERCEPTION(" &FieldParam &")}",ReturnFieldValue)
end if
Next
ReplaceCondition2=TempStr
End Function
'取得分页标志
Function GetPageStr(SqlLabel)
Dim slab:slab=split(SqlLabel,"(")(0)
slab=replace(slab,"{","")
GetPageStr="<script src=""" & KS.Setting(3) & "ks_inc/page.js""></script>" & vbcrlf
GetPageStr=GetPageStr & "<script language=""javascript"" defer>" & vbcrlf
GetPageStr=GetPageStr & "Page(1,'" & SqlLabel & "','" & Fcls.RefreshFolderID &"','" & KS.Setting(3) & "','plus/ajaxsql.asp','','','" & Fcls.RefreshInfoID & "');" & vbcrlf
GetPageStr=GetPageStr & "</script>" & vbcrlf
GetPageStr=GetPageStr & "<div id=""pagecontent""><div id=""c_" & slab & """></div></div>" & vbcrlf
GetPageStr=GetPageStr & "<div id=""fenye""><div id=""p_" & slab & """ align=""right""></div></div>" & vbcrlf
End Function
第三处:
'消除多余的循环体
Function CleanLabel(Content)
Dim regEx, Matches, Match,LoopTimes
Set regEx = New RegExp
regEx.Pattern = "\[loop=\d*][\s\S]*?\[/loop]"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(Content)
For Each Match In Matches
Content=Replace(Content,Match.value,"")
Next
CleanLabel=ReplaceCondition(Replace(Content,"$KS:Page$",vbcrlf))
CleanLabel=ReplaceCondition1(CleanLabel)
CleanLabel=ReplaceCondition2(CleanLabel)
End Function
'替换循环部分内容
注意:此标签在SQL标签中使用,红色为添加部分
使用案例:[loop=1]{$INTERCEPTION({$Field(ClassBasicInfo,Text,0,...,0,)}[]2[]1)}
{$INTERCEPTION({$Field(ClassDefineContent,Text,0,...,0,)}[]0[]0)}
[/loop]