网站运营
位置:首页>> 网站运营>> 让你的动易自动生成站内链接之二

让你的动易自动生成站内链接之二

 来源:asp之家 发布时间:2009-09-18 14:39:00 

标签:动易,站内,链接

继上次写了篇《让你的动易SW6自动生成站内链接》后有朋友提到了一个问题。如果说我不想重新生成文章,但又想把原来的这些文章的标题添加到站内链接,因为生成文章太慢太耗时间了。

  嗯,这个问题的确是值得我们关注的,因为大部分朋友的网站的内容不是一两百篇的问题,而是成千上万篇。所以要把这些原来就存在的文章的站内链接添加进去,还真是一个超大的工程。那么好吧,生成文章是很花时间,那么我们就来个不生成文章,但是照样把这些原本就存在的文章的标题添加到站内链接中!

  Come on,下面就来Diy修改动易吧。提示:上篇文章中的函数是要用到的。所以没有看上篇文章的朋友请自己去查看。以前的代码就不再贴上来了,不要因为没有添加上篇文章中的代码出错又来找我!

  1、找到Admin/Admin_CreateArticle.asp 文件,在Call CreateIndex语句后面添加如下语句

Case "CreateIndex"
Call CreateIndex

'以下部分为新添加的代码部分,添加的位置可以自己选择。
Case "UpdateKeyLink"
Call UpdateKeyLink

  2、在Admin/Admin_CreateArticle.asp 文件最后面添加以下函数:

  说明:以下函数其实只是用到该页面中生成文章的函数代码,然后把文件写入部分,以及其他读取和替换模板部分这些我们并不需要的部分给去掉了,这也是为什么这个自动生成站内链接功能可以这么快的原因,可能不是精简得最好的,你可以自己看下有什么可以再精简的。

Sub UpdateKeyLink()
'On Error Resume Next
ChannelID = PE_CLng(Request("ChannelID"))

Dim sql, strFields, ArticlePath
Dim strArticleContent
Dim tmpArticle, tmpTemplateID

sql = "select * from PE_Article where Deleted=" & PE_False & " and Status=3 and ReceiveType=0 and InfoPoint=0 And InfoPurview=0 and ChannelID=" & ChannelID&" order by UpdateTime desc,ClassID,ArticleID"

If IsAutoCreate = False Then
Response.Write "<b>正在生成" & ChannelShortName & "页面……请稍候!<font color='red'>在此过程中请勿刷新此页面!!!</font></b><br>"
Response.Flush
End If
Set rsArticle = Server.CreateObject("ADODB.Recordset")
rsArticle.Open sql, Conn, 1, 1
If rsArticle.Bof And rsArticle.EOF Then
TotalCreate = 0
iTotalPage = 0
rsArticle.Close
Set rsArticle = Nothing
Exit Sub
Else
If CreateType = 9 Or (CreateType = 8 And CreateItemType = 3)Then
TotalCreate = PE_Clng(Conn.Execute("select count(*) from PE_Article where Deleted=" & PE_False & " and Status=3 and ReceiveType=0 and InfoPoint=0 And InfoPurview=0 and ChannelID=" & ChannelID & " and (CreateTime is null or CreateTime<=UpdateTime)")(0))
Else
TotalCreate = rsArticle.RecordCount
End If

End If

PageTitle = ""
strFileName = ChannelUrl_ASPFile & "/ShowArticle.asp"
   
Call MoveRecord(rsArticle)
Call ShowTotalCreate(ChannelItemUnit & ChannelShortName)
Do While Not rsArticle.EOF
FoundErr = False
ArticleID = rsArticle("ArticleID")
ClassID = rsArticle("ClassID")
If CreateType = 7 Then ChannelID = rsArticle("ChannelID")
strNavPath = tmpNavPath
Call GetChannel(ChannelID)
Call GetClass
strPageTitle = tmpPageTitle
iCount = iCount + 1

If ClassPurview > 0 Or rsArticle("InfoPurview") > 0 Or rsArticle("InfoPoint") > 0 Then
Response.Write "<li><font color='red'>ID为 " & rsArticle("ArticleID") & " 的" & ChannelShortName & "因为设置了阅读权限,所以没有生成。</font></li>"
Response.Flush
Else
SpecialID = 0
CurrentPage = 1
ArticlePath = HtmlDir & GetItemPath(StructureType, ParentDir, ClassDir, rsArticle("UpdateTime"))
ArticleTitle = Replace(Replace(Replace(Replace(rsArticle("Title") & "", " ", " "), """, Chr(34)), ">", ">"), "<", "<")
ArticlePath = ArticlePath & GetItemFileName(FileNameType, ChannelDir, rsArticle("UpdateTime"), ArticleID)
tmpFileName = ArticlePath & FileExt_Item

Call CreatKeyLink(ArticleTitle, tmpFileName, 1)

End If
If Response.IsClientConnected = False Then Exit Do
If iCount Mod MaxPerPage_Create = 0 Then Exit Do
rsArticle.MoveNext
Loop
rsArticle.Close
Set rsArticle = Nothing
End Sub

以上函数有点熟悉吧,对就是把这个页面前面生成文章页面的函数修改了一下,把多余的,以及写入文件的部分不要了。换成了更新站内链接。

3、在Admin/Admin_Index_Left.asp 中增加后台接口

在此页面中找个适当的位置添加以下代码

Response.Write "<tr><td height=20><a href='Admin_CreateProduct.asp?ChannelID=1000&Action=UpdateKeyLink' target='main'>更新站内链接</a></td></tr>"

好了,完成了,超简单吧?三步完成,现在把后台刷新一下,然后在左侧导航中是不是多了个“更新站内链接”?好了,点击它试下?

PS:因为代码部分我是修改了很多地方的,此代码你移植过去可能会有些小问题,有什么问题可以发邮件给我,记住,请写清楚你所遇到的问题,以及错误描述。否则不回复,谢谢合作。

0
投稿

猜你喜欢

手机版 网站运营 asp之家 www.aspxhome.com