Helper Methods & Template Rendering Methods - Mura Docs v6

Helper Methods & Template Rendering Methods

There are many helper objects attached to the Mura Scope. Here are a few commonly used helper methods:

$.dspInclude()

This method is used to include a CFML file (.cfm) and will automatically generate the path to the site's "includes" directory. For example:

$.dspInclude('display_objects/custom/myFile.cfm');

… would include the file at …

/{SiteID}/includes/display_objects/custom/myFile.cfm

$.dspThemeInclude()

This method is used to include a CFML file (.cfm) and will automatically generate the path to the current theme's directory. For example:

$.dspThemeInclude('display_objects/myFile.cfm');

… would include the file at …

/{SiteID}/includes/themes/{ThemeName}/display_objects/myFile.cfm

$.dspObject()

This method is used to include a Mura display object. For example, Mura components, plugins, feeds, forms, and several other display objects (e.g.,  comment, site map, navigation, etc.).

$.dspObject({object type} ,{objectID} [,{siteId}]);

See the contentRenderer's dspObject method in Mura's Component API (http://www.getmura.com/mura/6/components/) for complete details.

<cfscript>
// Displaying a Mura Display Object:
$.dspObject({object type} ,{objectID} [,{siteId}]);
// Rendering a Feed:
$.dspObject('feed' ,{feedId | name});
// Rendering a Form:
$.dspObject('form' ,{contentId | title});
// Rendering a Component:
$.dspObject('component', {contentId | title});
// Rendering an Editable Attribute for Front-End Editing:
// This feature currently supports 'text' and 'htmlEditor' type attributes.
// The 'attribute' field is required.
$.renderEditableAttribute(
attribute='attributeName'
, type={'text'|'htmlEditor'}
, required={true|false}
, validation='blank or a JavaScript regex'
, message='Message to display if it does not pass validation'
, label='Form Field Label'
, value=$.content('attributeName')
, enableMuraTag={true|false}
);
</cfscript>

Usage

<cfoutput>
#$.renderEditableAttribute(
attribute='MyCustomVar'
, label='My Custom Var'
)#
#$.renderEditableAttribute(
attribute='MyCustomVar'
, label='My Custom Var'
, type='htmlEditor'
)#
</cfoutput>

Other Commonly Used Helper Objects

$.getContentRenderer();
$.getThemeRenderer();
$.getBean({beanType});
$.getPlugin({package|pluginID|moduleID});
$.getTopID();
$.getTopVar({varName}};
$.setDynamicContent({variableOrFunctionCall});
$.createHREF(
filename={filename}
// some of the optional arguments
, type={type}
, siteid={SiteID}
, contentID={ContentID}
, complete={complete}
, showMeta={showMeta}
, queryString={queryString}
);