CFMX 7 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 found here.
GENERAL
Site Name
#renderer.getSite().getSite()#
Site ID
#request.siteid#
Top Section Navigation Title
#renderer.getTopVar('menuTitle')#
Parent/Grandparent etc Navigation Title
<cfif arraylen(request.crumbData) gt 1>#request.crumbData[arraylen(request.crumbData)-1].menutitle#<cfelse></cfif>
Extended Attribute Value
<cfif len(request.contentBean.getExtendedAttribute('ATTRIBUTENAME')) > - #request.contentBean.getExtendedAttribute('ATTRIBUTENAME')#</cfif>
NAVIGATION
Primary Nav
#renderer.dspPrimaryNav(0)# Changing (0) to any number will output nested levels of navigation for Suckerfish style dropdown nav.
The necessary JS to enable drop down nav in IE6 can be found in global.js
Breadcrumb Nav
#renderer.dspCrumbListLinks("crumbList","» ")#
CSS HOOKS
Page-Specific
#renderer.CreateCSSid(request.contentBean.getMenuTitle())#
Section-Specific (Top Level Pages)
#renderer.gettopid()#
Depth-Specific
level#arrayLen(request.crumbdata)# ("level" can be anything you want, it's to make sure the css selector doesn't begin with a number)
CONTENT
Body Content w/ H2 & Breadcrumb Nav
#renderer.dspBody(request.contentBean.getbody(),request.contentBean.gettitle(),1)#
Body Content w/o H2 & Breadcrumb Nav
#renderer.dspBody(request.contentBean.getbody(),'',0)#
Display Regions
#renderer.dspObjects(1-8)# (Use any number between 1 and 8)
Conditional Extended Attribute
<cfif len(request.contentBean.getExtendedAttribute('htmlTitle')) > - #request.contentBean.getExtendedAttribute('htmlTitle')#</cfif><!--- htmlTitle 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=renderer.dspObjects(1) />
<cfif len(str)>#str#</cfif>
FUNCTIONS/FEATURES
Search Form
<form action="/go/#request.siteid#/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 request.contentBean.getCredits() neq "">#request.contentbean.getCredits()#</cfif>
"Read More" Link
#addlink(rsSection.type,rsSection.filename,'View Complete Description',rsSection.target,rsSection.targetParams,rsSection.contentid,request.siteid)#
Use a server-side include within Mura
[mura ]dspInclude('templates/inc/theFile.cfm')[/mura ]
Insert a specific component into a template
#renderer.dspObject('component','CONTENTID',request.siteid)#
Insert a specific component into a component or page
[mura ]dspObject('component','CONTENTID',request.siteid)[/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',request.siteid)[/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 #renderer.getSite().getSite()#" href="http://#cgi.script_name#/tasks/feed/?siteid=#request.siteid#&contentid=[CONTENT ID]&categoryid=[CATEGORY ID]&maxitems=20" />
USEFUL COLDFUSION 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())#