当前位置: 首页 > 技术文档 > 频道操作类详解

频道操作类详解

来源:LCMS企业网站管理系统 发表时间:2010-6-5 22:53:08 浏览次数:

core/asp/cls_channel.asp 频道操作类,最大程度简化模板制作。core/config.asp 默认变量名称为 c ,并定义 channel 为默认频道变量。

频道对象既是一个 Scripting.Dictionary 对象,直接可以使用 channle(key) 的方式取值。

类公共变量

  • {Int} Cls_Channel.Type_Article
    对应core/config.asp模板变量Template的文章类型数组下标,如果更改请重新设置。
    c.Type_Article = 1
    默认值:
    1

  • {Int} Cls_Channel.Type_Product
    对应core/config.asp模板变量Template的产品类型数组下标,如果更改请重新设置。
    c.Type_Product = 2
    默认值:
    2

  • {Int} Cls_Channel.Type_Resource
    对应core/config.asp模板变量Template的资源类型数组下标,如果更改请重新设置。
    c.Type_Resource = 3
    默认值:
    3

频道函数列表

  • <Function> {Object} Cls_Channel.New ()
    新建频道对象:类型为Cls_Channel
    set channel = c.New

  • <Function> {Boolean} Cls_Channel.IsGet
    检测是否成功获得频道,以及文章、产品和资源。
    set channel = c.GetThis
    if channel.IsGet then
        response.write channel("ChannelName") '获取成功,输出频道名称
    end if

  • <Function> {Boolean} Cls_Channel.Has
    检测是否获得频道列表,以及文章、产品和资源列表。
    dim news
    set news = channel.TopNode(10, "new", false) '获得频道下10篇最新文章
    if news.Has then
        response.write news(0)("Title") '获取成功,输出一条文章的标题
    end if

  • <Function> {Object} Cls_Channel.GetThis
    获得当前频道:根据Request.QueryString("id")方式获得。
    set channel = c.GetThis

  • <Function> {Object} Cls_Channel.GetByID (Int)
    根据频道ID获得频道。
    set channel = c.GetByID(1)

  • <Function> {Object} Cls_Channel.GetByName (String)
    根据频道名称获得频道。
    set channel = c.GetByName("LCMS简介")

  • <Function> {Object} Cls_Channel.GetByAlias (String)
    根据频道别名获得频道。
    set channel = c.GetByID("LCMS-jianjie")

  • <Function> {Object} Cls_Channel.Find (String)
    在下级频道中搜素一个频道:根据频道名称。
    dim anli
    set anli = channel.Find("用户案例")

  • <Function> {Object} Cls_Channel.Parent
    获得父级频道。
    dim parent
    set parent = channel.Parent

  • <Function> {Object} Cls_Channel.Children
    获得所有子频道:返回频道列表。
    dim children
    set children = channel.Children

  • <Function> {Object} Cls_Channel.Offspring
    获得所有后代频道:返回频道列表。
    dim offspring
    set offspring = channel.Offspring

  • <Function> {Object} Cls_Channel.Family
    获得所有家族频道:返回频道列表,从根频道算起。
    dim family
    set family = channel.Family

  • <Function> {Object} Cls_Channel.Parents
    获得所有父级频道:返回频道列表。
    dim parents
    set parents = channel.Parents

  • <Function> {Object} Cls_Channel.Siblings
    获得所有同级频道:返回频道列表。
    dim siblings
    set siblings = channel.Siblings

  • <Function> {Object} Cls_Channel.TopChannel
    获得所有顶级频道:返回频道列表。
    dim nav
    set nav = channel.TopChannel

  • <Function> {Object} Cls_Channel.AllChannel
    获得所有频道:返回频道列表。
    dim navigation
    set navigation = channel.AllChannel

  • <Function> {Object} Cls_Channel.IDCondition (String)
    生成当前频道(包括下级频道)为条件的SQL语句。
    dim sql
    sql = "select * from Articles where Status = 1 and " & channel.IDCondition("channleid")

  • <Sub> Cls_Channel.Location
    自动生成频道当前位置。
    channel.Location

  • <Sub> Cls_Channel.Nav
    自动生成顶级频道导航:UL/LI结构,UL ID="nav",当前频道样式"over"
    channel.Nav

  • <Sub> Cls_Channel.Navigation
    自动生成完整频道导航:UL/LI结构,UL ID="nav",当前频道样式"over"
    channel.Navigation

  • <Sub> Cls_Channel.Menu
    自动生成频道菜单:DL/DT/DD包裹,DL ID="menu",列表UL/LI结构,当前频道样式"over"
    channel.Menu

文章、产品及资源功能

  • <Function> {Object} Cls_Channel.TopNode (num, mode, image)
    取频道下前num条记录,返回列表对象:只针对文章、产品及资源频道类型有效,函数智能获取。
    dim news
    set news = channel.TopNode(10, "new", false)
    mode = 0 或 mode = "new":
    按照最新方式排序。
    mode = 1 或 mode = "hot":
    按照点击次数倒排序。
    mode = 2 或 mode = "top":
    按照权重排序。
    image = true:
    只取带图片的记录。
    image = false:
    忽略图片条件。

  • <Function> {Object} Cls_Channel.Pagination (mode, false)
    直接对频道下所有记录进行分页,返回列表对象:只针对文章、产品及资源频道类型有效,函数智能获取。
    dim news
    set news = channel.Pagination(0, false)

  • <Sub> Cls_Channel.PageList
    输出频道下记录分页页码。
    channel.PageList

  • <Function> {Object} Cls_Channel.MyChannel
    获得文章、产品及资源的频道。
    dim news
    set news = channel.Article(request.querystring("id"))
    if news.IsGet then
        set channel = news.MyChannel
    else
        response.end
    end if

  • <Function> {Object} Cls_Channel.Article (Int)
    获得一篇文章,返回频道对象类型:参数为文章ID。
    dim news
    set news = channel.Article(request.querystring("id"))

  • <Function> {Object} Cls_Channel.Product (Int)
    获得一件产品,返回频道对象类型:参数为产品ID。
    dim product
    set product = channel.Product(request.querystring("id"))

  • <Function> {Object} Cls_Channel.Resource (Int)
    获得一个资源,返回频道对象类型:参数为资源ID。
    dim resource
    set resource = channel.Resource(request.querystring("id"))

  • <Function> {Object} Cls_Channel.Prev
    获得上一条记录,返回频道对象类型:只针对文章、产品及资源记录有效,函数智能获取。
    dim prevnews
    set prevnews = news.prev

  • <Function> {Object} Cls_Channel.Next
    获得下一条记录,返回频道对象类型:只针对文章、产品及资源记录有效,函数智能获取。
    dim nextnews
    set nextnews = news.next