KesionCMS-函数标签轻松调用你想要的字段

来自站长百科
跳转至: 导航、​ 搜索

导航:返回上一页

KesionCMS-函数标签轻松调用你想要的字段



Kesioncms V6发布了一段时间了,使用过V6的朋友都知道科汛的系统函数标签已经是非常灵活了,更让人心动的是她的自定义样式输出(类似sql标签的循环体),但官方在考虑到整体性能的前提下,默认情况下只能用一些常见的字段


默认的可用字段如下:



小改科汛系统函数标签轻松调用你想要的字段.png

但这些可用字段有可能不能完全满足所有用户的需求,比如一些用户想调用文章的作者,来源等,那就实现不了了



没关系,如果有这个需求又不想用sql标签,只需要简单一步,就可以实现随意调用你想到的字段


V6开始的标签解释引擎已全面升级,扩展性极简单.科汛的系统函数标签解释文件主要在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表查看


参考来源[ ]