首先找到网站目录/inc/AspCms_MainClass.asp
增加主函数
Public Function parseSlideList(str) if not isExistStr(content,"{aspcms:"&str&"slidelist") then Exit Function dim match,matches,matchfield,matchesfield dim labelAttrLinklist,loopstrLinklist,loopstrLinklistNew,loopstrTotal dim vtype,vnum,whereStr,linkArray,linkUrlArray,linktextArray dim fieldName,fieldAttr,fieldNameAndAttr,fieldAttrLen dim i,labelRuleField dim m,namelen,deslen,m_des labelRule="{aspcms:"&str&"slidelist([\s\S]*?)}([\s\S]*?){/aspcms:"&str&"slidelist}" labelRuleField="\["&str&"slidelist:([\s\S]+?)\]" regExpObj.Pattern=labelRule set matches=regExpObj.Execute(content) for each match in matches labelAttrLinklist=match.SubMatches(0) loopstrLinklist=match.SubMatches(1) vtype=parseArr(labelAttrLinklist)("type") if isnul(vtype) or (vtype<>"a" and vtype<>"b" and vtype<>"c") then vtype="" ‘type 空 a b c if vtype="" then linkArray=split(slideImgs&vtype,",") linkUrlArray=split(slideLinks&vtype,",") linkTextArray=split(slideTexts&vtype,",") else linkArray=split(eval(slideImgs&vtype),",") linkUrlArray=split(eval(slideLinks&vtype),",") linkTextArray=split(eval(slideTexts&vtype),",") end if if not isarray(linkArray) then vnum=-1 else vnum=ubound(linkArray) regExpObj.Pattern=labelRuleField set matchesfield=regExpObj.Execute(loopstrLinklist) loopstrTotal="" for i=0 to vnum-1 loopstrLinklistNew=loopstrLinklist for each matchfield in matchesfield fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32)) fieldNameAndAttr=trimOuter(fieldNameAndAttr) m=instr(fieldNameAndAttr,chr(32)) if m > 0 then fieldName=left(fieldNameAndAttr,m - 1) fieldAttr = right(fieldNameAndAttr,len(fieldNameAndAttr) - m) else fieldName=fieldNameAndAttr fieldAttr = "" end if select case fieldName case "t" loopstrLinklistNew = replace(loopstrLinklistNew,matchfield.value,vnum+1) case "imgurl" loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,linkArray(i)) case "link" loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,linkUrlArray(i)) case "title" loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,linkTextArray(i)) case "width" loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,eval(slideWidth&vtype)) case "height" loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,eval(slideHeight&vtype)) case "i" loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,i+1) end select next loopstrTotal=loopstrTotal&loopstrLinklistNew next set matchesfield=nothing content=replaceStr(content,match.value,loopstrTotal) strDictionary.removeAll next set matches=nothing End Function
然后在文件中查找函数parseGlobal()增加解析标签代码
content=replaceStr(content,"{aspcms:slidelist}",parseSlideList(""))
大功告成!
在首页我们可以这样调用
其中的字段
[slidelist:link] [slidelist:imgurl]
{aspcms:slidelist type=a}
{/aspcms:slidelist}
{aspcms:slidelist type=b}
{/aspcms:slidelist}
{aspcms:slidelist type=d}
{/aspcms:slidelist}
时间: 2024-10-21 02:26:29