作者:佚名 文章来源:本站原创 点击数: 更新时间:2008-6-9 0:00:55  |
|
目的:解决动易文章频道下调用商城频道相关商品的问题
描述:有的时候,我们希望在文章频道的文章查看页面(内容页面)中把网站商城频道的相关商品也都显示出来。但是目前为止,动易2006包括其最新版本SiteWeaver™ 都没有解决这个问题。现在把我的方法贴上来与大家分享,顺便BS一下动易的开发人员和服务人员!
文件:Include/PowerEasy.Article.asp
函数:增加 GetCorreldrug (显示相关商品,这个函数名你可以取成自己想要的)
方法:增加如下语句及函数
调用:在内容页面你想要调用相关商品的地方添加标签 {$CorrelativeDrugs}
步骤1:大概是在Line 3063 找到
If InStr(strHtml, "{$CorrelativeArticle}") > 0 Then strHtml = Replace(strHtml, "{$CorrelativeArticle}", GetCorrelative(10, 40, 1, 0, 1))
然后在其后面添加语句:(目的,替换该标签) If InStr(strHtml, "{$CorrelativeDrugs}") > 0 Then strHtml = Replace(strHtml, "{$CorrelativeDrugs}", GetCorreldrug(10, 40, 1, 0, 1))
步骤2:在相关文章函数下面添加
'================================================= '函数名:GetCorreldrug '作 用:显示相关商品 '参 数:ArticleNum ----最多显示多少篇文章 ' TitleLen ----标题最多字符数,一个汉字=两个英文字符 ' OrderType ---- 排序方式,1--按文章ID降序,2--按文章ID升序,3--按更新时间降序,4--按更新时间升序,5--按点击数降序,6--按点击数升序,7--按评论数降序,8--按评论数升序 ' OpenType ---- 文章打开方式,0为在原窗口打开,1为在新窗口打开 ' Cols ---- 每行的列数。超过此列数就换行。 '================================================= Private Function GetCorreldrug(ArticleNum, TitleLen, OrderType, OpenType, Cols) Dim rsCorreldrug, sqlCorreldrug, strCorreldrug, iCols, iTemp Dim strKey, arrKey, i, MaxNum iTemp = 1 If PE_CLng(Cols) <> 0 Then iCols = PE_CLng(Cols) Else iCols = 1 End If
If ArticleNum > 0 And ArticleNum <= 100 Then sqlCorreldrug = "select top " & ArticleNum Else sqlCorreldrug = "Select Top 5 " End If strKey = Mid(rsArticle("Keyword"), 2, Len(rsArticle("Keyword")) - 2) If InStr(strKey, "|") > 1 Then arrKey = Split(strKey, "|") MaxNum = UBound(arrKey) If MaxNum > 2 Then MaxNum = 2 strKey = "((P.Keyword like '%|" & Replace(Replace(arrKey(0),"[",""),"]","") & "|%')" For i = 1 To MaxNum strKey = strKey & " or (P.Keyword like '%|" & Replace(Replace(arrKey(i),"[",""),"]","") & "|%')" Next strKey = strKey & ")" Else strKey = "(P.Keyword like '%|" & strKey & "|%')" End If sqlCorreldrug = sqlCorreldrug & " P.ProductID,P.ProductName,P.ProductType,P.Price,Price_Original,P.Price_Market,P.Price_Member,Discount,BeginDate,EndDate,P.UpdateTime,P.ProductThumb" If UseCreateHTML > 0 Then sqlCorreldrug = sqlCorreldrug & ",C.ParentDir,C.ClassDir from PE_Product P left join PE_Class C on P.ClassID=C.ClassID" Else sqlCorreldrug = sqlCorreldrug & " from PE_Product P" End If sqlCorreldrug = sqlCorreldrug & " where P.Deleted=" & PE_False & " and P.EnableSale=" & PE_True & ""
sqlCorreldrug = sqlCorreldrug & " and " & strKey & " Order by P.ProductID desc" Set rsCorreldrug = Conn.Execute(sqlCorreldrug)
If TitleLen <= 0 Or TitleLen > 255 Then TitleLen = 80 If rsCorreldrug.BOF And rsCorreldrug.EOF Then strCorreldrug = R_XmlText_Class("ShowArticle/NoCorreldrug", "<li>没有相关药品</li>") Else Do While Not rsCorreldrug.EOF Call GetChannel(rsCorreldrug("ChannelID")) '取得该相关药品的频道URL即ChannelUrl If UseCreateHTML > 0 Then 'strCorreldrug = strCorreldrug & "<li><a href=""" & GetProductUrl(rsCorreldrug("ParentDir"), rsCorreldrug("ClassDir"), rsCorreldrug("UpdateTime"), rsCorreldrug("ProductID")) & """ title="""&rsCorreldrug("ProductName")&""">" & GetSubStr(rsCorreldrug("ProductName"), TitleLen, ShowSuspensionPoints) & "</a></li>" strCorreldrug = strCorreldrug & "<li><a href=""" & GetProductUrl2(rsCorreldrug("ParentDir"), rsCorreldrug("ClassDir"), rsCorreldrug("UpdateTime"), rsCorreldrug("ProductID")) & """ title="""&rsCorreldrug("ProductName")&""">" & GetSubStr(rsCorreldrug("ProductName"), TitleLen, ShowSuspensionPoints) & "</a></li>" Else strCorreldrug = strCorreldrug & "<li><a href=""" & GetProductUrl2("", "", "", rsCorreldrug("ProductID")) & """ title="""&rsCorreldrug("ProductName")&""">" & GetSubStr(rsCorreldrug("ProductName"), TitleLen, ShowSuspensionPoints) & "</a></li>" End If rsCorreldrug.MoveNext Loop End If rsCorreldrug.Close Set rsCorreldrug = Nothing GetCorreldrug = strCorreldrug End Function |