Code Snippets
Note: An additional trailing space is added to all [mura ] tags on this page to keep them from rendering. Be sure to remove this additional space when using any snippets.
The examples on this page are not supported by CFMX7. You'll need to use older, deprecated examples found here.
General
Site Name
#$.siteConfig('site')#
Site ID
#$.event('siteid')#
Top Section Navigation Title
#$.getTopVar('menuTitle')#
Parent/Grandparent etc Navigation Title
<cfif arraylen($.event('crumbData')) gt 1>#$.createHREF(filename=$.getTopVar('filename'))#</cfif>
Extended Attribute Value
<cfif len($.content('ATTRIBUTENAME')) >#$.content('ATTRIBUTENAME')#</cfif>
Navigation
Primary Nav
#$.dspPrimaryNav(viewDepth="1",id="navPrimary",displayHome="Always",closePortals="true",showCurrentChildrenOnly="false")#
The necessary JS to enable drop down nav in IE6 can be found in global.js
Breadcrumb Nav
#$.dspCrumbListLinks("crumbList","» ")#
CSS Hooks
Page-Specific
#$.createCSSid($.content('menuTitle'))#
Section-Specific (Top Level Pages)
#$.gettopid()#
Depth-Specific
level#arrayLen($.event('crumbdata'))# ("level" can be anything you want, it's to make sure the css selector doesn't begin with a number)
Content
Creating Custom Image Sizes
$.content().getImageURL(size='small') $.content().getImageURL(size='medium') $.content().getImageURL(size='large')
or
$.content().getImageURL(height=100,width=100)
Example:
<img src="#$.content().getImageURL(height=100,width=100)#" />
Or from the contentNavBean
item=it.next(); item.getImageURL(height=100,width=100)
This wraps the contentRenderer.createHREFForImage which now has the height and width arguments.
Body Content w/ H2 & Breadcrumb Nav & Associate Image
#$.dspBody(body=$.content('body'),pageTitle=$.content('title'),crumbList=0,showMetaImage=1)#
Body Content w/o H2 & Breadcrumb Nav & Associated Image
#$.dspBody(body=$.content('body'),pageTitle='',crumblist=0,showMetaImage=0)#
Display Regions
#$.dspObjects(1-8)# (Use any number between 1 and 8)
Conditional Extended Attribute
<cfif len($.content('customVar')) >#$.content('customVar')#</cfif><!--- customVar is just an example attribute --->
Show Display Region Content Conditionally if it exists
This can be used to create "dynamic" templates that change layout based on whether or not content exists in a display region.
<cfset str=$.dspObjects(1) /> <cfif len(str)>#str#</cfif>
Functions/Features
Search Form
Create a page called "Search" or remove the action attribute for this example.
<form action="#$.createHREF(filename='search')#" id="searchForm">
<input type="text" value="Enter Search Terms" onclick="this.value='';" onblur="if(this.value==''){this.value='http://';}" class="text" name="keywords"/>
<input type="submit" value="Search" class="submit" />
<input type="hidden" name="display" value="search"/>
<input type="hidden" name="newSearch" value="true"/>
<input type="hidden" name="noCache" value="1"/>
</form>
Get "Credits" text input value if it exists (Found in "meta" tab in edit page)
<cfif $.content('credits') neq "">#$.content('credits')#</cfif>
"Read More" Link
#$.addlink(item.getValue('type'),item.getValue('filename'),'View Complete Description',item.getValue('target'),item.getValue('targetparams'),item.getValue('contentID'),item.getValue('siteID'))#
Use a server-side include within Mura
[mura ]$.dspInclude('display_objects/custom/theFile.cfm')[/mura ]
Insert a specific component into a template
#$.dspObject('component','CONTENTID')#
Insert a specific component into a component or page
[mura ]$.dspObject('component','CONTENTID')[/mura ]
These can be used to call any object from Mura, i.e. a Component, a Local Index, a Form, etc. If you are placing this inside a display object or something "inside" the renderer, lose the "renderer." at the beginning
Insert a Local Index or Remote Feed into a component or page
[mura ]$.dspObject('feed','FEEDID')[/mura ]
Add user to a specific Mailing List from a non-mailing list form
<input type="hidden" name="mlid" value="[MLID]"><input type="hidden" name="doaction" value="subscribe">
Alternate Content (Meta RSS)
(Replace bracketed items with actual values to define the parameters for the global feed. These can all be found in the form for Local Content Indexes. Use with caution, this essentially documents ALL published content)
<link rel="alternate" type="application/rss+xml" title="Global RSS Feed for #$.siteConfig('site')#" href="http://#cgi.script_name#/tasks/feed/?siteid=#$.event('siteID')#=#&contentid=[CONTENT ID]&categoryid=[CATEGORY ID]&maxitems=20" />
Useful CFML Variables
Current Date
#dateFormat(now(),"medium")#
Alternates to "medium" are "short", "long", "dddd,mmmm,yyyy", "ddd,mmm,yyy", "dd,mm,yy"
Current Year
#year(now())#