在 CF8 中,我有一个工作 cftree,每个节点(多个节点)都有一个 RSS 提要。问题是我目前没有使用绑定,这意味着加载页面时会读取所有提要,这需要很长时间。我想要做的是将 cftreeitem 绑定到 cfc 以便仅在用户选择父 cftreeitem 而不是在页面加载时读取提要。该页面未引发错误,但提要的所有子节点均未显示在父节点下。
cfm:
<cfform name="RSS_exercise">
<cftree name="Xfeeds" format="html" cache="no">
<cftreeitem value="elite" display="<div style='color:##4c4c4c'>ELITE FTS</div>" queryasroot="true" expand="no">
<cftreeitem value="" bind="cfc:components.rssQ.getEliteRSS({cftreeitempath}, {cftreeitemvalue})">
</cftree>
</cfform>
cfc:
<cffunction name="getEliteRSS" access="remote" returntype="any" hint="gets EliteFTS RSS feed">
<cfargument name="itemPath" type="string" required="false"/>
<cfargument name="itemValue" type="string" required="false"/>
<cffeed source="http://feeds2.feedburner.com/EliteftsArticles" properties="eliteProps" query="eliteRSS">
<cfset var feedArray = ArrayNew(1) />
<cfset var feed = StructNew() />
<cfset var i = 1 />
<cfoutput query="eliteRSS">
<cfset feed.value = "" />
<cfset feed.display = "#title# <div style='color:gray'>Published: #DateFormat(publisheddate)#</div><br/>" />
<cfset feed.href = "#rsslink#" />
<cfset feed.target = "_blank" />
<cfset feed.parent = "elite" />
<cfset feed.queryAsRoot = "false" />
<cfset feed.expand = "no" />
<cfset feedArray[i] = Duplicate(feed) />
<cfset var i = "i++" />
</cfoutput>
<cfreturn feedArray />
</cffunction>
非常感谢您的帮助。
进行了以下更改,现在获得了输出,但它是嵌套/循环的,我无法获得顶级父节点,因此它们并不都是平坦的。这样做的目的是为了让 1 个父级在检查之前不会加载提要。
cfm
<cfform name="RSS_exercise">
<cftree name="Xfeeds" format="html" cache="no">
<cftreeitem bind="cfc:components.rssQ.getEliteRSS({cftreeitempath}, {cftreeitemvalue})">
</cftree>
</cfform>
cfc
<cffunction name="getEliteRSS" access="remote" returntype="array" output="no" hint="gets EliteFTS RSS feed">
<cfargument name="itemPath" type="string" required="false"/>
<cfargument name="itemValue" type="string" required="false"/>
<cfset var feedArray = ArrayNew(1) />
<cfset var feed = StructNew() />
<cfset var i = 1 />
<cffeed source="http://feeds2.feedburner.com/EliteftsArticles" properties="eliteProps" query="eliteRSS">
<cfloop query="eliteRSS">
<cfset StructClear(feed) />
<cfset feed.value = "1" />
<cfset feed.display = "#title# <div style='color:gray'>Published: #DateFormat(publisheddate)#</div><br/>" />
<cfset feed.href = "#rsslink#" />
<cfset feed.target = "_blank" />
<cfset feed.parent = "elite" />
<cfset feed.queryAsRoot = "false" />
<cfset feed.expand = "no" />
<cfset feedArray[i] = Duplicate(feed) />
<cfset i++ />
</cfloop>
<cfreturn feedArray />
</cffunction>