新云4 中加入了新东西,xlst,目前论坛对这个的研究不多。
经过几个小时的研究,先是在论坛中4.0板块中从第一页翻到第十页,发现有两个人问到了这个问题,不过版主没给出解决方法。
直接在论坛中搜索xlst,没有帖子。
没办法只好自己研究代码了,虽然从来没搞过asp,xlst也是用新云后才开始看的。
但是有PHP的基础,代码看起来不算特别困难。
通过对代码的反向查找,终于找到了inc/template.inc这个文件,其中:
===================================================
channid = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("channelid"))
classid = CheckIDlist(iXMLDom.documentElement.getAttribute("classid"))
specialid = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("specialid"))
maxnum = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("maxnum"))
stype = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("type"))
setcache = NewAsp.CheckStr(iXMLDom.documentElement.getAttribute("setcache"))
rootNode = NewAsp.CheckStr(iXMLDom.documentElement.getAttribute("node"))
imgWidth = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("width"))
imgHeight = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("height"))
strLength = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("length"))
datemode = NewAsp.CheckStr(iXMLDom.documentElement.getAttribute("datemode"))
showcate = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("showcate"))
showdate = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("showdate"))
showimg = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("image"))
strTarget = NewAsp.CheckStr(iXMLDom.documentElement.getAttribute("target"))
NoTitle = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("notitle"))
Eachline = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("eachline"))
strlen = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("strlen"))
strSQL = iXMLDom.documentElement.getAttribute("sql")&""
strField = iXMLDom.documentElement.getAttribute("field")&""
==============================================================
注意最后一个参数:strField = iXMLDom.documentElement.getAttribute("field")&""
看到Field字样,大概知道有戏了。
于是:{$xml:newslist file="newslist.xslt" field="username," setcache="0" type="0" showuser="1" channelid="{$channelid}" classid="0" maxnum="20" length="56" showcate="1" showdate="1" datemode="MM-dd"}
添加filed字段: field="username," (注意这里要加一个英文逗号)
因为下面sql的组合是这样的:SQL=" A.ArticleID,A.ClassID,A.ColorMode,A.FontMode,A.title,A.BriefTopic,A.subtitle,A.OuterLinks,"&strField&"A.Author,A.AllHits,A.WriteTime,A.HtmlFileDate,A.isBest,A.ImageUrl,A.star,A.IsTop,"
在xlst文件中如果需要引用的话就用这个:<xsl:value-of select="@username"/>
最终效果图: