Last active
December 14, 2023 10:42
-
-
Save stevewithington/7322583 to your computer and use it in GitHub Desktop.
Mura CMS : In version 6.1, you can now obtain a Content Bean's extended attributes as a struct, and even pass in the Extend Set Name to get specific sets of extended attributes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
<cfscript> | |
// Access all of the current content bean's extended attributes | |
$.content().getExtendedAttributes(); | |
// Access a specific Extend Set's attributes of the current content bean | |
$.content().getExtendedAttributes(name='Your Extend Set Name Goes Here'); | |
// Access a query/recordset of the current content bean's extended attributes | |
$.content().getExtendedAttributesQuery(); | |
// Access a specific Extend Set's attributes query/recordset | |
$.content().getExtendedAttributesQuery(name='Your Extend Set Name Goes Here'); | |
// Access all extended attributes of a content item when looping through an iterator | |
// Content Bean of desired section | |
cBean = $.getBean('content').loadBy(title='Blog'); | |
// Feed Bean | |
fBean = $.getBean('feed').addParam( | |
relationship='and' | |
, field='tcontent.parentid' | |
, datatype='varchar' | |
, criteria=cBean.getContentID() | |
); | |
// The Iterator | |
it = fBean.getIterator(); | |
</cfscript> | |
<cfif it.hasNext()> | |
<ul> | |
<cfloop condition="it.hasNext()"> | |
<cfset item = it.next() /> | |
<cfset rsAttributes = item.getExtendedAttributesQuery() /> | |
<!--- To select only attributes of a specific Extend Set, just pass in the name of the Extend Set ---> | |
<!--- <cfset rsAttributes = item.getExtendedAttributesQuery(name='Your Extend Set Name Goes Here') /> ---> | |
<li> | |
<h3>#item.getValue('menuTitle')#</h3> | |
<cfif rsAttributes.recordcount> | |
<ul> | |
<cfloop query="rsAttributes"> | |
<cfif Len(rsAttributes.attributeValue[currentrow])> | |
<li>#rsAttributes.label[currentrow]#: #rsAttributes.attributeValue[currentrow]#</li> | |
</cfif> | |
</cfloop> | |
</ul> | |
</cfif> | |
</li> | |
</cfloop> | |
</ul> | |
</cfif> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good stuff Steve!