Content Bean
The content
bean/object includes data about a Mura content item, such as the title, summary, body, etc. In addition, there are several content-specific helper methods included. For example, you could get an iterator of any children of the content item, what specific categories the content item has been assigned to, etc.
See the Mura Scope's content subscope to access the same information when working with a content item being used in the current request.
Syntax
The following examples illustrate how to "get" and/or "set" various attributes of the content
bean/object. Use whichever syntax feels best to you.
Loading the Bean
You can load a content
bean/object by any of the following attributes:
- contentid
- contenthistid
- filename
- remoteid
- title
- urltitle
<cfset contentBean = m.getBean('content').loadBy(title='Home')>
Once you have a variable to reference the desired bean/object, you can use the example Getters and Setters below.
Getters
contentBean.get('attributeName') contentBean.get{AttributeName}() contentBean.getValue('attributeName')
Setters
contentBean.set('attributeName', 'someValue') contentBean.set{AttributeName}('someValue') contentBean.setValue('attributeName', 'someValue')
Usage
Use the content
bean/object to access and/or manipulate a content item.
Attributes
The table below lists available attributes.
Attribute | Description |
---|---|
active | Whether the content item is active. |
approvalchainoverride | Whether to ignore approval chain, if applied. |
approvalgroupid | The current approval chain GroupID the content item is assigned to. |
approvalstatus | The approval status of the content item. |
approved | Whether the content item is approved. |
assocfilename | The name of the file of the primary associated image/file. |
body | The main content/body of the content item. |
categoryid | A comma-delimited list of CategoryIDs associated with the content item. |
changesetid | The ChangeSetID the specific content item version is associated with, if any. |
childtemplate | Default template to be applied to children, if any. |
contenthistid | A unique identifier for the specific version of the content item. |
contentid | A unique identifier for the content item. |
created | Date/time the content was originally created. |
credits | The credits field of the content item. Similar to a byline. |
depth | A numeric representation of number of levels deep the content item resides in relation to the "Home" page. |
display | Whether to display the content item. |
displayinterval | If "display" is set to "Per Schedule", a JSON-encoded string representing the scheduled display interval. |
displaystart | If "display" is set to "Per Schedule", the date/time to begin displaying the content item. |
displaystop | If "display" is set to "Per Schedule", the date/time to stop displaying the content item. |
expires | The content expiration date field of the content item. |
featurestart | If the content item is featured, the date/time to begin featuring it. |
featurestop | If the content item is featured, the date/time to stop being featured. |
fileext | The file extension of the primary associated image/file. |
fileid | The FileID of the primary associated image/file. |
filename | The URL to the content item, excluding the domain name. |
filesize | The file size of the primary associated image/file. |
htmltitle | The HTML Title field of the content item. |
imageheight | If the content item is a Folder, and imagesize is "custom" the height in pixels to use for images. |
imagesize | If the content item is a Folder, the pre-defined size to use for images (e.g., small, medium, large, custom, etc.) |
imagewidth | If the content item is a Folder, and imagesize is "custom", the width in pixels to use for images. |
inheritobjects | Whether the content item is inheriting display objects from an ancestor. |
isfeature | Whether the content item is featured in the section. |
ishome | Whether the content item is the "Home" page. |
islocked | Whether the content item is locked, if type is a file. |
isnav | Whether the content item should be shown in navigational objects generated by Mura. |
isnew | Whether the content item is new. |
lastupdate | The date/time the content item was last updated. |
lastupdateby | The name of the user who last updated the content item. |
lastupdatebyid | The UserID of the user who last updated the content item. |
majorversion | The major version number of the content item, if type is a file. |
menutitle | The Menu Title field of the content item. |
metadesc | The Meta Description of the content item. |
metakeywords | The Meta Keywords of the content item. |
minorversion | The Minor Version of the content item, if the type is a file. |
mobileexclude | Whether to exclude the content item from navigation objects on mobile devices. |
moduleassign | If content type is a Form or Component, a comma-delimited list of ModuleIDs of modules to allow the Form/Component to be used in. Essentially, the answer to the "Where would you like to use this Component?" question. |
moduleid | ModuleID of the content item. |
newfile | This is the field you set new primary associated files, when creating new content programatically. |
nextn | If content type is a Folder, the number of records to display on each page. |
notes | The Notes field of the content item. |
objectparams | The objectparams of the content item. |
orderno | The Order Number of the content item, if the parent is using "Manual" sort. |
parentid | The ContentID of the direct parent of the content item. |
path | A comma-delimited list of ContentIDs representing the ancestry of the content item. |
releasedate | The Official Release Date field of the content item. |
remoteid | A special field for developer's to use. May load the content item by this field. It does not have to be unique. Typically, used to store a unique identifier to associate the content item to an external data store. |
remotepubdate | A special field for developer's to use when importing or associating content to an external data store. |
remotesource | A special field for developer's to use when importing or associating content to an external data store. Typically, the name of the external data. |
remotesourceurl | A special field for developer's to use when importing or associating content to an external data store. Typically, the domain of the external data. |
remoteurl | A special field for developer's to use when importing or associating content to an external data store. Typically, the full URL to the external content. |
restricted | Whether the content item is restricted. |
restrictgroups | A comma-delimited list of GroupIDs to restrict access to. |
searchexclude | Whether to exclude the content item from Mura's search results. |
siteid | The SiteID the content item is associated with. |
sortby | If content type is Folder, which field to sort by. |
sortdirection | If content type is Folder, which direction to sort by. |
status | The Status of the content item (e.g., Published, Draft, etc.). |
statusid | The StatusID of the content item. |
subtype | Subtype of the content item. |
summary | The Summary field of the content item. |
tags | A comma-delimited list of default tags. |
target | Whether to open in a new browser window. |
template | The layout template applied directly to the content item. If empty, Mura will traverse up the tree until it locates an applied template, and if none are found or the applied template is not found, will use the default.cfm layout template. |
title | The main Title field of the content item. |
type | The type of the content item (e.g., Page, Folder, Calendar, Link, File, etc.) |
urltitle | The URL Title field of the content item. |
Helper Methods
When working with content, the following content
bean/object's helper methods may be quite useful.
getCategoriesIterator()
Returns an iterator of categories the content item has been associated with.
<cfset it = contentBean.getCategoriesIterator()> <!--- Loop over the iterator ---> <cfif it.hasNext()> <ul> <cfloop condition="it.hasNext()"> <cfset item = it.next()> <li> #esapiEncode('html', item.get('name'))# </li> </cfloop> </ul> <cfelse> <!--- Content item has not been categorized ---> </cfif>
getKidsCategoryIterator()
Returns an iterator of categories that children of the content item have been associated with.
<cfset it = contentBean.getKidsCategoryIterator()> <!--- Loop over the iterator ---> <cfif it.hasNext()> <ul> <cfloop condition="it.hasNext()"> <cfset item = it.next()> <li> #esapiEncode('html', item.get('name'))# </li> </cfloop> </ul> <cfelse> <!--- No child categories exist ---> </cfif>
getRelatedContentIterator()
Returns an iterator of related content items.
<cfset it = contentBean.getRelatedContentIterator()> <!--- Loop over the iterator ---> <cfif it.hasNext()> <ul> <cfloop condition="it.hasNext()"> <cfset item = it.next()> <li> <a href="#item.get('url')#"> #esapiEncode('html', item.get('title'))# </a> </li> </cfloop> </ul> <cfelse> <!--- No related content items exist ---> </cfif>
You can also optionally pass in a specific Related Content Set name.
<cfset it = contentBean.getRelatedContentIterator(name='Related Videos')>
getCommentsIterator()
Returns an iterator of comments associated with the content item.
<cfset it = contentBean.getCommentsIterator()> <!--- Loop over the iterator ---> <cfif it.hasNext()> <ul> <cfloop condition="it.hasNext()"> <cfset item = it.next()> <li> <div class="comments-datetime"> #LSDateFormat(item.get('entered'))# #LSTimeFormat(item.get('entered'))# </div> <div class="comments-text"> #esapiEncode('html', item.get('comments'))# </div> <div class="comments-author"> #esapiEncode('html', item.get('name'))# </div> </li> </cfloop> </ul> <cfelse> <!--- No comments exist ---> </cfif>