|
以下是引用南柯一梦在2008-3-14 8:38:37的发言:昨天看到有网友在论坛里问,昨天晚上抽空整理了一下,现不敢一人独享,如果你怕回复麻烦,就不要看了,请不要对我人身进行攻击,呵呵
以下内容只有回复后才可以浏览1、首先打开文件KS_Cls\KS_LabelCls.asp 找到Case "GETARTICLELIST" '栏目文章列表函数 在该行上面插入以下代码 Case "GETRNDARTICLELIST" '栏目随机文章列表函数 ChangeLableToFunction = GetRndArticleList(L_Arr(1), L_Arr(2), L_Arr(3), L_Arr(4), L_Arr(5), L_Arr(6), L_Arr(7), L_Arr(8), L_Arr(9), L_Arr(10), L_Arr(11), L_Arr(12), L_Arr(13), L_Arr(14), L_Arr(15), L_Arr(16), L_Arr(17), L_Arr(18), L_Arr(19), L_Arr(20),L_Arr(21), L_Arr(22),L_Arr(23), L_Arr(24),L_Arr(25), L_Arr(26),L_Arr(27), L_Arr(28),L_Arr(29), L_Arr(30), L_Arr(31), L_Arr(32)) 然后在该文件末尾处End Class之前插入以下函数,函数体如下:
'取得栏目随即调用文章列表 Function GetRndArticleList(ChannelID,FolderID,I_S_C,S_C_N, OpenType, A_P, num, R_H,T_Len, ByVal S_Str, Col, PicTF, NavType, Nav, MoreType, MoreLink, SplitPic, DateRule,DateAlign, T_Css, DateCss,SpecialID,NewTF,HotTF,P_T,DivID,DivCss,UlID,ULCss,LiID,LICss,LabelID) If LabelID<>"ajax" and P_T>2 Then GetArticleList="<span id=""ks" & LabelID & "_" & FolderID & "_" & Application(KS.SiteSN & "RefreshFolderID") & "_0""></span>":Exit Function ElseIf P_T>2 Then P_T=P_T-2 End If Dim SqlStr, A_PStr,M_L_S, O_T_S,C_F_T,Param If FolderID = "-1" Then FolderID = Application(KS.SiteSN & "RefreshFolderID") C_F_T = True Else C_F_T = False End If If FolderID = "" Then FolderID = "0" Select Case A_P Case "1":A_PStr = " And Recommend=1" Case "2":A_PStr = " And Popular=1" Case "3":A_PStr = " And Strip=1" End Select
A_PStr=A_PStr & " And " & KS.GetSpecialPara(SpecialID) If Lcase(Left(Trim(S_Str),2))<>"id" Then S_Str=S_Str & ",ID Desc" If FolderID = "0" Then Param="" Else If CBool(I_S_C) = True Then Param="Tid In (" & KS.GetFolderTid(FolderID) & ") And" Else Param="Tid='" & FolderID & "' And" '---------------------------------2007.3.13代码更改开始--------------------------------- '获取指定的ID Dim RndRs,RsCount,strIDList,i,tempsql Dim IDArray(),strArray() tempsql="SELECT ID,Title,Tid,ReadPoint,InfoPurview,Fname,Changes,AddDate,Popular,NewsID,ShowComment,Comment,TitleType,TitleFontColor,TitleFontType FROM " & KS.C_S(ChannelID,2) &" Where " & Param & " Verific=1 AND DelTF=0 " & A_PStr & " ORDER BY ID Desc" Set RndRs=Server.CreateObject("ADODB.RecordSet") RndRS.Open tempsql,conn,1,1 RsCount=RndRs.RecordCount If RsCount>0 Then ReDim IDArray(RsCount) i=0 Do While Not RndRs.Eof IDArray(i)=RndRs(0) i=i+1 RndRs.MoveNext Loop ReDim strArray(num) Randomize For i=0 To num-1 strArray(i)=IDArray(Int(Rnd()*RsCount)) Next strIDList=Join(strArray,",") End If RndRs.Close '---------------------------------2008.3。13代码更改结束--------------------------------- SqlStr = "SELECT TOP " & num & " ID,Title,Tid,ReadPoint,InfoPurview,Fname,Changes,AddDate,Popular,NewsID,ShowComment,Comment,TitleType,TitleFontColor,TitleFontType FROM " & KS.C_S(ChannelID,2) &" Where " & Param & " Verific=1 AND DelTF=0 " & A_PStr & " AND ID IN("& strIDList &") ORDER BY IsTop Desc," & S_Str
O_T_S = KS.G_O_T_S(OpenType) If MoreLink <> "" And FolderID <> "0" And C_F_T = False Then M_L_S = KS.GetMoreLink(P_T,Col, R_H, MoreType, MoreLink, KS.GetFolderPath(FolderID), O_T_S) GetRndArticleList = KS_A_L(ChannelID,SqlStr, M_L_S, S_C_N, O_T_S, R_H, T_Len, Col, PicTF, NavType, Nav, SplitPic, DateRule, DateAlign, T_Css, DateCss,NewTF,HotTF,P_T,DivID,DivCss,UlID,ULCss,LiID,LICss) End Function 2、复制文件Admin\Include\Label\GetArticleList.asp,将其更名为GetRndArticleList.asp保存至Admin\Include\Label\目录,打开GetRndArticleList.asp,批量将字符串GetArticleList替换为GetRndArticleList,保存
3、打开文件Admin\Include\AddFunctionLabel.asp,在代码
<%Case 2%> 之前插入以下代码 <option value="Label/GetRndArticleList.asp?ChannelID=<%=SQL(0,I)%>&PageTitle=新建栏目<%=SQL(3,I)%>随机列表标签&FolderID=<%=FolderID%>">|-栏目<%=SQL(3,I)%>随机列表标签</option>
4、使用方法:在后台添加“系统函数标签”,然后选“栏目文章随机列表标签”
5、如果数据库中记录过多,调用时需消耗资源,没有特殊需要,请不要使用该标签 [此贴子已经被作者于2008-3-14 8:39:11编辑过]
|