用DW打开ks_cls/kesion.label.functioncls.asp
找到构造sql查询语句的通用函数,大约在438行吧
'加载模型通用查询字段
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.Rank"
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.Rank 是我加上的,就这么简单一步,你的系统函数标签的自定义样式里就已经直接用{@Rank}这样的标签调用出文章的作者了,其它模型类似,具体想要调用的字段可以打开ks_article表查看
1.那这么简单,官方为什么不把所有字段都加进去呢?这样就不用用户自己加了,我方便?
答:我上面已经说到了考虑到性能问题,查询字段应该尽量的少.所以也不是说你查询越多越好.
2.为什么我按上面修改了,但我用{@字段名称}还是查询不出来呢?
答:检查标签属性里的范围有没有指定具体的模型,只有指定具体模型才有效,否则她查询的是KS_ItemInfo表
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
相关文章
KesionCMS X2.0 去掉文章检查重名的修改2018-01-22
kesion Sql 函数标签空值判断2017-07-24
KESION CMS X1 标签清单2017-07-24
kesion 图片系统编辑器替换2017-07-05
科讯kesion输出图片系统里的图片合集的方法2017-06-01
kesion科讯搜索分页{@search.showpage}样式修改2017-05-27
kesion科讯分页样式pagenumlist修改2017-05-26
kesion科讯内容页上一篇、下一篇样式修改2017-05-26
kesion科讯当前文章高亮SQL函数表达式2017-05-25
KesionCMS 文章,图片、下载等内容页实现添加时间年、月、日单独获取的修改方法2016-12-23