知足网ziz88.com
个人博客 电脑技巧 学习经验 优秀教程资源 软件素材模版
科讯首页调用作者等任意字段修改方法
  经验文章>科汛CMS>浏览文章

科汛的系统函数标签解释文件主要在kesion.label.functioncls.asp这个文件中,那么请你用DW打开ks_cls/kesion.label.functioncls.asp

找到构造sql查询语句的通用函数,大约在200多行吧

  '加载模型通用查询字段
  Public Sub LoadField(ByVal ModelID,ByVal PrintType,ByVal PicStyle,ByVal ShowPicFlag,ByRef FieldStr,ByRef TableName,ByRef Param)
     If ModelID="0" Then
    TableName = "[KS_ItemInfo]"
    FieldStr  = "I.ChannelID,I.InfoID as ID,I.Title,I.Tid,I.Intro,I.PhotoUrl,I.AddDate,I.Inputer,I.Popular,I.Fname,I.Hits"
    If PrintType=2 or (instr(LabelStyle,"{@photourl}")>0 and PrintType>2) Then Param = Param & " And I.PhotoUrl<>''"
   Else
    TableName=KS.C_S(ModelID,2)
    Select Case KS.C_S(ModelID,6)
     Case 1
      FieldStr  = "I.ID,I.Title,I.Tid,I.Inputer,I.Fname,I.AddDate,I.Popular,I.Hits"
      FieldStr=FieldStr & ",I.TitleType,I.TitleFontColor,I.TitleFontType"
      If PrintType>=2 Then  FieldStr=FieldStr & ",I.PhotoUrl,I.Intro" : If PrintType=2 or (instr(LabelStyle,"{@photourl}")>0 and PrintType>2) Then Param = Param & " And I.PicNews=1"
      If PrintType>=3 Then  FieldStr=FieldStr & ",I.ReadPoint"
     Case 2 
      FieldStr  = "I.ID,I.Title,I.Tid,I.Inputer,I.Fname,I.AddDate,I.Popular,I.Hits"
      If PrintType>=2 Then FieldStr=FieldStr & ",I.PhotoUrl,I.PictureContent As Intro"
      If PrintType>=3 Then FieldStr=FieldStr & ",I.ReadPoint"
     Case 3 
      FieldStr  = "I.ID,I.Title,I.Tid,I.Inputer,I.Fname,I.AddDate,I.Popular,I.Hits"
      If PrintType>=2 Then FieldStr=FieldStr & ",I.PhotoUrl,I.DownContent As Intro,I.DownSize,I.Rank"
      If PrintType>=3 Then FieldStr=FieldStr & ",I.ReadPoint"
     Case 4 
      FieldStr  = "I.ID,I.Title,I.Tid,I.Inputer,I.Fname,I.AddDate,I.Popular,I.Hits"
      If PrintType>=2 Then FieldStr=FieldStr & ",I.PhotoUrl,I.FlashContent As Intro,I.Author,I.Rank"
      If PrintType>=3 Then FieldStr=FieldStr & ",I.ReadPoint"
     Case 5 
      FieldStr  = "I.ID,I.Title,I.Tid,I.Inputer,I.Fname,I.AddDate,I.Popular,I.Hits"
      If PrintType>=2 Then FieldStr=FieldStr & ",I.PhotoUrl,I.ProIntro As Intro,I.BigPhoto,I.Price_market,I.Price_member,I.Price,I.Price_Original,I.Discount,I.Promodel,I.Point"
      If KS.ChkClng(ParamNode.getAttribute("producttype"))<>0 Then Param =Param & " And I.ProductType="&KS.ChkClng(ParamNode.getAttribute("producttype"))
     Case 7 
      FieldStr  = "I.ID,I.Title,I.Tid,I.Inputer,I.Fname,I.AddDate,I.Popular,I.Hits"
      If PrintType>=2 Then FieldStr=FieldStr & ",I.PhotoUrl,I.MovieContent As Intro"
      If PrintType>=3 Or PicStyle=13 Or PicStyle=14 Or PicStyle=15 Then FieldStr=FieldStr & ",I.MovieAct,I.MovieDY,I.MovieDQ,I.MovieTime,I.MovieYY,I.ReadPoint,I.Rank"
      If PrintType=2 And PicStyle=15 Then FieldStr=FieldStr & ",I.MovieDy"
     Case 8 
      FieldStr  = "I.ID,I.Title,I.Tid,I.Inputer,I.Fname,I.AddDate,I.Popular,I.Hits,I.TypeID"
      If PrintType>=2 Then FieldStr=FieldStr & ",I.PhotoUrl,I.GQContent As Intro"
      If PrintType>=3 Or PicStyle=16 Or PicStyle=17 Then FieldStr=FieldStr & ",I.ValidDate,I.ContactMan,I.Tel,I.Address,I.Province,I.City,I.CompanyName"
      If KS.ChkClng(ParamNode.getAttribute("typeid"))<>0 Then Param =Param & " And I.TypeID="&KS.ChkClng(ParamNode.getAttribute("typeid"))
     Case Else 
      FieldStr  = "I.ID,I.Title,I.Tid,I.PhotoUrl,I.AddDate,I.Inputer,I.Popular,I.Fname,I.Hits"
      If PrintType=2 or (instr(LabelStyle,"{@photourl}")>0 and PrintType>2) Then Param = Param & " And I.PhotoUrl<>''"
    End Select
    If PrintType=4 Then FieldStr=FieldStr & GetDiyFieldStr(ModelID)
   End If
  End Sub

 

如果看懂代码的用户,相信很容易看出来是根据模型构造的查询字段,这里我们就以文章模型为例,找到如下代码

 

Case 1
      FieldStr  = "I.ID,I.Title,I.Tid,I.Inputer,I.Fname,I.AddDate,I.Popular,I.Hits,I.Author"
      FieldStr=FieldStr & ",I.TitleType,I.TitleFontColor,I.TitleFontType"
      If PrintType>=2 Then  FieldStr=FieldStr & ",I.PhotoUrl,I.Intro" : If PrintType=2 or (instr(LabelStyle,"{@photourl}")>0 and PrintType>2) Then Param = Param & " And I.PicNews=1"
      If PrintType>=3 Then  FieldStr=FieldStr & ",I.ReadPoint"

 

其中红色的,i.author 是我加上的,就这么简单一步,你的系统函数标签的自定义样式里就已经直接用{@author}这样的标签调用出文章的作者了,其它模型类似,具体想要调用的字段可以打开ks_article表查看


疑问:

1.那这么简单,官方为什么不把所有字段都加进去呢?这样就不用用户自己加了,我方便?

答:我上面已经说到了考虑到性能问题,查询字段应该尽量的少.所以也不是说你查询越多越好.

2.为什么我按上面修改了,但我用{@字段名称}还是查询不出来呢?

答:检查标签属性里的范围有没有指定具体的模型,只有指定具体模型才有效,否则她查询的是KS_ItemInfo表



编号:星羽

知足网 ZIZ88.com于2020年04月16日整理

加微信: 15604958501 QQ: 8233398 69元开通无限期会员


Copyright © 2020 - 2020 网站备案/许可证号:辽ICP备20001173号

本站所有内容来源于网络,如果内容侵犯您的权益请联系QQ 8233398 进行修 改处理