Catch My BFusion Presentations on CFMeetup!

I received confirmation from Charlie Arehart, the online ColdFusion Meetup organizer, that I'll be giving both of my BFusion presentations on CFMeetup. So the good news is if you won't be able to attend BFusion/BFlex this year, then at least you'll still be able to see my presentations. However, they won't be "hands-on," which will hopefully allow me to trim my 90-minute presentations down to the typical 60-minute mark we've grown accustomed to on CFMeetup.

So, if you're interested, please mark your calendars!

Getting Started with Mura CMS

November 12, 2009, 12:00 p.m. (noon) Eastern

Looking for a ColdFusion-powered, open source content management system? Drop in and learn how to have a site up and running in less than sixty minutes!  Within one hour, I'll walk through each of these steps to help you get started using Mura CMS:

  • Installing Mura CMS
  • Creating your first site
  • Creating your first form
  • Creating your first Mura component
  • Setting up navigation
  • Creating a custom 404 page
  • Exploring built-in features & objects
  • Exploring Mura templates & themes

Integrating Your Custom Design with Mura CMS

December 3, 2009 12:00 p.m. (noon) Eastern

Tired of trying to shoe-horn your custom design into someone else's content management system? Drop in and learn how to fully integrate your custom CSS and HTML with Mura CMS, a comprehensive, ColdFusion-powered, open source content management system. In less than sixty minutes, I'll attempt to cover:

  • Exploring Mura templates & themes
  • Integrating your custom CSS & HTML
  • Creating Mura components
  • Creating Feeds/Indexes
  • Creating Custom Feeds/Indexes

*If you haven't already done so, it might behoove you to catch part one, "Getting Started with Mura CMS."

How to Send Confirmation Emails to Form Submitters in Mura CMS

A question came up in the Mura CMS forums about "sending a confirmation message automatically" that I thought other developers and/or users of Mura CMS might find helpful.

When you create a form in Mura CMS, there are a couple of convenient fields available. One field allows for a comma-separated list of email addresses to receive notification whenever the form is submitted. Another field is a text area for displaying a "confirmation message" to the person who submits the form.

One field that isn't currently available is a checkbox to "send copy to submitter." A good reason for this could simply be that since a form could contain any number of unique fields and field names, it could be very difficult to programmatically allow for something as unique as this.

So I wrote a simple custom display object that will essentially check for a form field called "email" and if it is valid, send a confirmation message to the submitter (assuming the submitter's email is contained within the "email" form field). Lost yet? I hope not.

First, you'll want to create a custom display object. you can copy the code below and save it to/as "[siteid]/includes/display_objects/custom/dsp_email_confirmation.cfm"


<cfsilent>
<!---

    Document:        dsp_email_confirmation.cfm
    Version:        20091005.01
    Author:            Steve Withington | www.stephenwithington.com
    
    Purpose:        I send email confirmations to form submitters.
    
    Instructions:    Assuming you've placed this file in/as:
                    "[siteid]/includes/display_objects/custom/dsp_email_confirmation.cfm"
                    
                    Go to "Forms" in your admin, select the form you want to use this script
                    in, go to the "Confirmation Message" text area, then copy + paste this:
                    
                    [mura]dspInclude('display_objects/custom/dsp_confirmation_email.cfm')[/mura]
                    
                    This could be the only line of text in your Confirmation Message text area
                    since now you can modify the confirmation text below. However, any
                    text in the "Confirmation Message" form field will also be display on
                    the screen.
                    
                    The confirmationText below can even be a dynamic field that's passed in
                    on form submission, etc.

--->

<cfsavecontent variable="confirmationText">
<cfoutput>Thank you for for your inquiry. A representative will contact you shortly. For immediate assistance, feel free to call 800.555.1212.</cfoutput>
</cfsavecontent>
</cfsilent>
<cfoutput><p class="success">#confirmationText#</p></cfoutput>
<cfif structKeyExists(request, "email") and isValid("email", request.email)>
    <cfsilent>
        <cfset site = application.settingsManager.getSite(request.siteID) />
        <cfset success=true />
        <cftry>
            <cfset email=application.serviceFactory.getBean('mailer') />
            <cfset email.sendText(confirmationText, form.email, form.email, site.getSite(), request.siteid, form.email) />
            <cfcatch>
                <cfset success=false />
            </cfcatch>
        </cftry>
    </cfsilent>
    <cfoutput>
        <cfif success>
            <!--- if successful, a confirmation message can be displayed here --->
            <p class="success"><em>A confirmation has also been sent to your email.</em></p>
            <cfelse>
            <!--- if an error occurs, an error message can be displayed here --->
            <p class="error">Sorry, we experienced a problem in our attempt to send you a confirmation via email.</p>
        </cfif>
    </cfoutput>
    <cfelse>
    <!--- you can display an error message if the email address provided is not valid --->
    <p class="error">Unfortunately, the email address you provided was not a valid email address.</p>
</cfif>

Next, you'll want to go to your "Forms" section in your admin area, select the form you want to use this script in, go to the "Confirmation Message" text area, then copy and past this in:


[mura]dspInclude('display_objects/custom/dsp_email_confirmation.cfm')[/mura]

You can then simply modify the confirmation message within the script, or even pass one in dynamically.

Hope this helps!

Using ColdFusion to Generate Meta Keywords and Description For Mura CMS

As with most content management systems, Mura CMS offers users the ability to enter a "summary" and "keywords" for each page (among several other options). The problem is, many users fail to utilize these fields. So I whipped up a couple of simple custom display objects to address this problem.

The meta keyword generator will read the main "content" of the page, parse it and then dynamically create a unique listing of keywords. I also use a custom list of keywords to delete common keywords such as "a, in, the," etc., which can easily be modified. This makes for good SEO (search engine optimization) too since you're actually generating keywords based on the actual contents of the page! Let's save the following file as "[siteid]/includes/display_objects/custom/dspMetaKeywordGenerator.cfm"


<cfsilent>
<!---

    Document:        dspMetaKeywordGenerator.cfm
    Version:        20091023.01
    Author:            Stephen Withington | www.stephenwithington.com
    
    Purpose:        I generate meta keywords based on the body content.
    
    Instructions:    Assuming you save this file to:
                    "[siteid]/includes/display_objects/custom/dspMetaKeywordGenerator.cfm"
                    
                    Locate your current meta keywords tag and replace with the following code:
        
                    <cfif len(trim(event.getContentRenderer().getMetaKeywords()))>
                        <meta name="keywords" content="#HTMLEditFormat(event.getContentRenderer().getMetaKeywords())#" />
                        <cfelse>
                        #event.getContentRenderer().dspInclude('display_objects/custom/dspMetaKeywordGenerator.cfm')#
                    </cfif>
                    
                    Typically, the meta keywords tag is found in this file:
                    "[siteid]/includes/themes/[themeName (i.e., "merced")]/templates/inc/html_head.cfm"
                    
    Notes:            Currently ONLY reads the body content and does not take any other content
                    into consideration. (i.e., content objects, etc.)

                    META KEYWORD GENERATOR PROCESS
                    Take the body content then:
                    1.    remove html
                    2.    remove puncuation
                    3.    remove whitespace, line breaks and convert to a list
                    4.    remove duplicate words
                    5.    remove common words (i.e., a, an, the, etc.)
                        - list can be modified in the variable "commonWords" below.
                    6.    sort the list (not necessary, but useful)
    
    Revision Log:    
    20091005.01 - sjw - first draft.
    20091023.01 - sjw - updated mura methods to reflect current best practice: event.getContentRenderer() and event.getContentBean() vs. renderer and request.contentbean, etc.

--->


<!--- LIST OF COMMON WORDS TO BE REMOVED --->
<cfset commonWords = "a, also, an, and, and, are, as, at, be, but, by, for, from, had, have, he, his, i, in, is, it, of, on, or, that, the, they, this, to, too, was, what, who, with" />

<!--- GRAB THE BODY CONTENT --->
<cfset str = event.getContentBean().getBody() />

<!--- helper functions from CFLib.org --->
<cfscript>
/**
* Case-insensitive function for removing duplicate entries in a list.
* Based on dedupe by Raymond Camden
*
* @param list List to be modified. (Required)
* @return Returns a list.
* @author Jeff Howden (cflib@jeffhowden.com)
* @version 1, July 2, 2008
*/

function listDeleteDuplicatesNoCase(list) {
var i = 1;
var delimiter = ',';
var returnValue = '';
if(ArrayLen(arguments) GTE 2)
    delimiter = arguments[2];
    list = ListToArray(list, delimiter);
    for(i = 1; i LTE ArrayLen(list); i = i + 1)
    if(NOT ListFindNoCase(returnValue, list[i], delimiter))
        returnValue = ListAppend(returnValue, list[i], delimiter);
    return returnValue;
}

/**
* Delete items from a list.
*
* @param variable An item, or a list of items, to remove from the list. (Required)
* @param qs The actual list to parse. Can be blank. (Optional)
* @return Returns a string.
* @author Alessandro Chisari (ruchizzy@hotmail.com)
* @version 1, May 17, 2006
*/

function listdelete(variable){
//var to hold the final string
var string = "";
//vars for use in the loop, so we don't have to evaluate lists and arrays more than once
var ii = 1;
var thisVar = "";
var thisIndex = "";
var array = "";
var qs = "";
if(arrayLen(arguments) GT 1)
qs = arguments[2];
//put the query string into an array for easier looping
array = listToArray(qs,",");
//now, loop over the array and rebuild the string
for(ii = 1; ii lte arrayLen(array); ii = ii + 1){
thisIndex = array[ii];
thisVar = thisIndex;
//if this is the var, edit it to the value, otherwise, just append
if(not listFindnocase(variable,thisVar))
string = listAppend(string,thisIndex,",");
}
//return the string
return string;
}
</cfscript>

<cfif len(trim(str))>
    <!--- 1. remove html (using built-in mura method) --->
    <cfset str = event.getContentRenderer().stripHTML(str) />
    <!--- 2. remove punctuation (this regex ain't pretty, but it works) --->
    <cfset str = REReplace(str, "[;\\/:""*?<>|\!\+\-\=\.`\##\&_\(\)\[\]\%\^\$\@~\',\{\}]+", "", "ALL") />

    <!--- 3. remove whitespace, line breaks and convert to a list --->
    <cfset str = REReplace(str, "\s|\r?\n", ",", "ALL") />
    <!--- 4. remove duplicate words --->
    <cfset str = listDeleteDuplicatesNoCase(str) />
    <!--- 5. remove common words --->    
    <cfset str = listdelete(commonWords,str) />
    <!--- 6. sort the list --->
    <cfset str = listSort(lcase(str), "text") />
</cfif>

</cfsilent>
<cfoutput><meta name="keywords" content="#str#" /></cfoutput>

The meta description generator will also read the main "content" of the page and grab the first twenty-five (25) words to automatically create the meta description. This also makes for good SEO since the description matches what's actually found on the page. Let's save the following file at "[siteid]/includes/display_objects/custom/dspMetaDescriptionGenerator.cfm"


<cfsilent>
<!---

    Document:        dspMetaDescriptionGenerator.cfm
    Version:        20091023.01
    Author:            Stephen Withington | www.stephenwithington.com
    
    Purpose:        I generate a meta description based on the body content.
    
    Instructions:    Assuming you save this file to:
                    "[siteid]/includes/display_objects/custom/dspMetaDescriptionGenerator.cfm"
                    
                    Locate your current meta description tag and replace with the following code:
        
                    <cfif len(trim(event.getContentRenderer().getMetaDesc()))>
                        <meta name="description" content="#HTMLEditFormat(event.getContentRenderer().getMetaDesc())#" />
                        <cfelse>
                        #event.getContentRenderer().dspInclude('display_objects/custom/dspMetaDescriptionGenerator.cfm')#
                    </cfif>

                    Typically, the meta description tag is found in this file:
                    "[siteid]/includes/themes/[themeName (i.e., "merced")]/templates/inc/html_head.cfm"
                    
    Notes:            Currently ONLY reads the body content and does not take any other content
                    into consideration. (i.e., content objects, etc.)

                    META DESCRIPTION GENERATOR PROCESS
                    Take the body content then:
                    1.    remove html
                    2.    remove whitespace, line breaks
                    3.    since Google will cut off anything more than
                        155(roughly) characters, let's limit this to the first 25 words.
    
    Props:            Ben Nadel's Post "Displaying A Blog Teaser":
                    http://www.bennadel.com/index.cfm?dax=blog:1718.view
                    John Whish's (www.aliaspooryorik.com/blog/) comments on Ben's Post above.
    
    Revision Log:    
    20091005.01 - sjw - first draft.
    20091023.01 - sjw - updated mura methods to reflect current best practice: event.getContentRenderer() and event.getContentBean() vs. renderer and request.contentbean, etc.
    
--->


<!--- GRAB THE BODY CONTENT --->
<cfset str = event.getContentBean().getbody() />

<cfif len(trim(str))>
    <!--- 1. remove html (using built-in mura method) --->
    <cfset str = event.getContentRenderer().stripHTML(str) />
    <!--- 2. remove whitespace, line breaks and replace with a space between each word --->
    <cfset str = REReplace(str, "[\s|\r?\n]+", " ", "ALL") />    
    <!--- 3. limit to the first 25 words --->
    <cfset javaArray = CreateObject("java","java.util.Arrays") />
    <cfset wordArray = javaArray.copyOf(str.Split( " " ), 26) />
    <cfset str = ArrayToList(wordArray, " ") />
</cfif>

</cfsilent>
<cfoutput><meta name="description" content="#trim(str)#" /></cfoutput>

How To Use

Since there may be users who actually do use the description and/or keywords fields in the admin area of Mura CMS, you want to be sure to check for that first. So, all we need to do is locate where the meta tags are being displayed at, and then replace with some simple code. In most installations, the meta tags can be found in this file "[siteid]/includes/themes/[themeName (i.e., "merced")]/templates/inc/html_head.cfm."


<cfif len(trim(event.getContentRenderer().getMetaDesc()))>
    <meta name="description" content="#HTMLEditFormat(event.getContentRenderer().getMetaDesc())#" />
    <cfelse>
    #event.getContentRenderer().dspInclude('display_objects/custom/dspMetaDescriptionGenerator.cfm')#
</cfif>

<cfif len(trim(event.getContentRenderer().getMetaKeywords()))>
    <meta name="keywords" content="#HTMLEditFormat(event.getContentRenderer().getMetaKeywords())#" />
    <cfelse>
    #event.getContentRenderer().dspInclude('display_objects/custom/dspMetaKeywordGenerator.cfm')#
</cfif>

Hope this helps!

More Entries

© 2026, Stephen J. Withington, Jr.  |  Hosted by Hostek.com

Creative Commons License   |   This work is licensed under a Creative Commons Attribution 3.0 Unported License.