当前位置: 首页 > 图文教程 > 网页制作 > CMS技巧 > PJBlog首页调用日志的实现方法

CMS技巧
Zblog帮助:模板文件与模板标签
Joomla教程:模板覆盖方式修改系统输出
Joomla教程:为Joomla插件创建语言包
Joomla教程:文章页面中显示指定的模块
Joomla教程:控制Section中的分类列表页面的显示方式
Joomla教程:mod-rewrite是否真的被开启
在Joomla自定义HTML模块组合使用Google小工具
Joomla教程:本地搭建的Joomla站点发送邮件
Joomla教程:在Who is online模块中显示用户名
dedecms教程:栏目页面转换为单独页面
CMS可用性测评:帮助找到适合自己的内容管理系统
Joomla中文教程:构建多重站点
Joomla教程:在templateDetails.xml中添加语言文件声明
Joomla教程:为页面和模块添加独立的自定义Class
Joomla教程:为“read more”链接添加对应的文章标题
Joomla教程:查看并修改模板的CSS
Joomla中文教程:创建并使用插件对文章内容进行修改
Joomla教程:网站首页第一次加载时播放一次Flash动画
Joomla教程:禁止未分类文章被站内搜索
Joomla教程:去掉分类文章列表中的文章序号

CMS技巧 中的 PJBlog首页调用日志的实现方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 35 ::
收藏到网摘: n/a

今天把博客首页调用一篇日志。现把方法整理下来供大家分享。

用EditPlus建立一个TOP.asp文件
<!--#include file="const.asp" -->
<!--#include file="conn.asp" -->
<!--#include file="common/cache.asp" -->
<!--#include file="common/function.asp" -->
<!--#include file="common/ubbcode.asp" -->
<%
'==================================
'  首页调用文件
'==================================
'读取Blog设置信息
  getInfo(1)
  
Response.Charset = "UTF-8"
Response.Expires=60

Dim cate_ID,FeedCate,FeedTitle,memName,FeedRows,TagID
Dim showType,titleLength,authorLength

cate_ID=CheckStr(Request.QueryString("cateID"))
TagID=CheckStr(Request.QueryString("Tag"))
showType=Request.QueryString("showType")
titleLength=Request.QueryString("titleLength")
authorLength=Request.QueryString("authorLength")

if IsInteger(titleLength)=false then titleLength=20
if IsInteger(authorLength)=false then authorLength=6    

FeedCate=False

IF IsInteger(TagID) = True Then
   SQLFiltrate="log_tag LIKE '%{"&TagID&"}%' AND "
   Else
   SQLFiltrate=""
End IF

IF IsInteger(cate_ID) = False Then
    SQL="Select TOP 10 L.log_ID,L.log_Title,l.log_Author,L.log_PostTime,C.cate_Name,C.cate_ID FROM blog_Content AS L,blog_Category AS C Where "&SQLFiltrate&" C.cate_ID=L.log_cateID AND L.log_IsShow=true AND L.log_IsDraft=false and C.cate_Secret=false orDER BY log_PostTime DESC"
Else
    SQL="Select TOP 10 L.log_ID,L.log_Title,l.log_Author,L.log_PostTime,C.cate_Name,C.cate_ID FROM blog_Content AS L,blog_Category AS C Where log_cateID="&cate_ID&" AND "&SQLFiltrate&" C.cate_ID=L.log_cateID AND L.log_IsShow=true AND L.log_IsDraft=false and C.cate_Secret=false orDER BY log_PostTime DESC"
    FeedCate=True
End IF

Dim RS,DisIMG,i
Set RS=Conn.ExeCute(SQL)
if RS.EOF or RS.BOF then
    ReDim FeedRows(0,0)
else
   if FeedCate then FeedTitle=SiteName & " - " & RS("cate_Name")
    FeedRows=RS.getrows()
end if
RS.close
set RS=nothing
Conn.Close
Set Conn=Nothing

if ubound(FeedRows,1)=0 then
            %>
            document.write ("没有找到任何日志")
            <%
else
    for i=0 to ubound(FeedRows,2)
         select case showType     
             case 1:
                %>              
                    document.write ("<div><span style=\"float:right\"><%=DateToStr(FeedRows(3,i),"Y-m-d")%></span>[<a href=\"<%=SiteURL&"default.asp?cateID="&FeedRows(5,i)%>\" target=\"_blank\"><%=toUnicode(FeedRows(4,i))%></a>]<a href=\"<%=SiteURL&"default.asp?id="&FeedRows(0,i)%>\" target=\"_blank\" title=\"<%=toUnicode(FeedRows(1,i))%>\"><%=toUnicode(CutStr(FeedRows(1,i),titleLength))%></a></div>")
                <%                 
             case 2:
                %>              
                    document.write ("<div><span style=\"float:right\"><a href=\"<%=SiteURL%>\" title=\"<%=toUnicode(FeedRows(2,i))%>\"><%=toUnicode(CutStr(FeedRows(2,i),authorLength))%></a></span><a href=\"<%=SiteURL&"default.asp?id="&FeedRows(0,i)%>\" target=\"_blank\" title=\"<%=toUnicode(FeedRows(1,i))%>\"><%=toUnicode(CutStr(FeedRows(1,i),titleLength))%></a></div>")
                <%                 
             case 3:
                %>              
                    document.write ("<div><span style=\"float:right\"><%=DateToStr(FeedRows(3,i),"Y-m-d")%></span><a href=\"<%=SiteURL&"default.asp?id="&FeedRows(0,i)%>\" target=\"_blank\" title=\"<%=toUnicode(FeedRows(1,i))%>\"><%=toUnicode(CutStr(FeedRows(1,i),titleLength))%></a></div>")
                <%        
             case 4:
                %>              
                    document.write ("<div><a href=\"<%=SiteURL&"default.asp?id="&FeedRows(0,i)%>\" target=\"_blank\" title=\"<%=toUnicode(FeedRows(1,i))%>\"><%=toUnicode(CutStr(FeedRows(1,i),titleLength))%></a></div>")
                <%    
             case 5:
                %>                        
                    document.write ("<div><a href=\"<%=SiteURL&"default.asp?id="&FeedRows(0,i)%>\" target=\"_blank\" title=\"<%=toUnicode(FeedRows(1,i))%>\"><%=toUnicode(CutStr(FeedRows(1,i),titleLength))%></a></div>")
                <%    
                case else:
                %>              
                    document.write ("<div><span style=\"float:right\"><a href=\"<%=SiteURL%>\" title=\"<%=toUnicode(FeedRows(2,i))%>\"><%=toUnicode(CutStr(FeedRows(2,i),authorLength))%></a></span>[<a href=\"<%=SiteURL&"default.asp?cateID="&FeedRows(5,i)%>\" target=\"_blank\"><%=toUnicode(FeedRows(4,i))%></a>]<a href=\"<%=SiteURL&"default.asp?id="&FeedRows(0,i)%>\" target=\"_blank\" title=\"<%=toUnicode(FeedRows(1,i))%>\"><%=toUnicode(CutStr(FeedRows(1,i),titleLength))%></a></div>")
                <%         
         end select

    next
end if

function toUnicode(str) 'To Unicode
    dim i, unicodeF, getUnicode
    for i=1 to len(str)
        unicodeF=Mid(str,i,1)
        getUnicode=getUnicode & chr(38) & chr(35) & chr(120) & Hex(ascw(unicodeF)) & chr(59)
    next
    toUnicode=getUnicode
end function
%>


记住,文件格式是UTF-8。
如果像我的博客调用一篇日志就找到代码select top 部分,把10改为1就可以了。

然后,在首页需要调用的部分加代码
<script type="text/javascript" src="top.asp?showType=1&titleLength=20&authorLength=5&cateID=14&tag=7"></script>

参数:
showType 输出类型,类型有五种 
留空 = [分类]标题+作者
1 = [分类]标题+日期 
2 = 标题+作者
3 = 标题+日期
4 = 标题

titleLength 标题长度
authorLength 作者名称长度
cateID 分类号
tag 标签tag_id序号(注意不是tag名称,是tag对应的ID号)