New Plugin for Mura CMS: MuraMetaGenerator

In honor of Mura's new and improved App Store, I've release another plugin for Mura CMS into the wild called MuraMetaGenerator™. In a nutshell, this allows Mura CMS to auto-generate meta keywords and descriptions for your pages.

Why Should I Use This?

There could be a number of reasons why someone would want to use MuraMetaGenerator™. One of the best reasons is that most Authors and Editors either don't have the time and/or the knowledge of what information to put in these fields to begin with.

Also, since search engines change their algorithms daily and actually rely less and less on meta keywords and meta descriptions, why not spend your time going through the actual content of your pages and making sure your content contains the information you want indexed by search engines? After all, MuraMetaGenerator™ derives its information based on the actual page content which means you'll be following 'White Hat' Search Engine Optimization (SEO) techniques so your search engines rankings will most likely grow organically over time.

So go ahead and let MuraMetaGenerator™ do it for you! You can grab it from http://www.getmura.com/index.cfm/app-store/apps/murametagenerator/

BFusion/BFlex 2010: ColdFusion and Flex Training at Indiana University

Looking for some live, hands-on ColdFusion and/or Flex training and education? Then you'll want to attend BFusion/BFlex 2010. The event is hosted in Bloomington, Indiana at none other than the Indiana University campus! The event will be held Saturday, September 11, 2010 and Sunday, September 12, 2010. Mark your calendars now and be sure to visit their web site for additional details and registration information.

For those who might be curious, I've thrown my name in the hat to present (again) on Mura CMS. I'm not certain if I'll be speaking or not yet, but I plan on attending either way. So if you're interested in learning more about Mura CMS live, in-person and hands-on, be sure to check back here for details on that. If you have any suggestions on what you would like to know about Mura, feel free to leave your comments for me here too.

Hope to see you there! Peace.

Using ColdFusion to Parse CSV via JavaLoader and OpenCSV

Recently I needed a quick and easy way to parse a CSV file with ColdFusion, and while there are a few projects floating around out in the wild, I had used OpenCSV in the past and remembered how easy it was to use.

While I've seen a few examples for ColdFusion users on how to parse and read a CSV file with OpenCSV, they've all used Java's FileReader to do it. This meant you had to have the file stored on your server somewhere and then get the full path to its location. For example, C:\csvfiles\sample.csv. In addition, most all of the examples I've found assumed you had OpenCSV installed somewhere in your server's classpath.

Unfortunately, I couldn't rely on this method for a number of reasons. The primary reason was because I was building this as a plugin for Mura CMS. So, if it's going to be a plugin, I can't just assume everyone has OpenCSV installed. In addition, Mura offers three different file storage options: 1) locally, 2) Amazon S3 and 3) database. While we could easily use Java's FileReader method with the first option, the other two would bomb.

My first stroke of luck was that Mark Mandel contributed a nifty little project called JavaLoader to the ColdFusion community awhile back. I was also fortunate because Mura offers a way to serve most of its files via the URL. So, using a wee bit of Java and JavaLoader, I can read in the URL of a CSV file in much the same way as the FileReader method.

So for completeness, let's look at both options and then you can decide which one would work best for you.

sample.csv

You can use any csv file that you want to. This is one I put together for my recent project.


LocationName,Lat,Lng,Address,Phone,InfoWindow,Zindex,Icon
Chicago White Sox,,,"333 W 35th St, Chicago, IL 60609",(312) 674-1000,,1,
Cleveland Indians,,,"2401 Ontario St, Cleveland, OH 44115",(216) 241-8888,,2,
Detroit Tigers,,,"2100 Woodward Ave, Detroit, MI 48201",(313) 962-4000,,3,
Kansas City Royals,,,"1 Royal Way, Kansas City, MO 64129",(816) 921-8000,,4,
Minnesota Twins,,,"351-413 5th Ave N, Minneapolis, MN 55401",(612) 659-3400,,5,

Parsing CSV With FileReader


<cfscript>
    csvFile = ExpandPath("/sample.csv");
    csvData = [];

    // FileReader
    fileReader = createobject("java","java.io.FileReader");
    fileReader.init(csvFile);

    // use JavaLoader to load OpenCSV
    paths = [ExpandPath("/opencsv-2.2/deploy/opencsv-2.2.jar")];
    loader = CreateObject("component", "javaloader.JavaLoader").init(paths);

    csvReader = loader.create("au.com.bytecode.opencsv.CSVReader");
    csvReader.init(fileReader);
    csvData = csvReader.readAll();

    // release system resources
    csvReader.close();
    fileReader.close();
</cfscript>
<cfdump var="#csvData#" />

Parsing CSV With URL and InputStreamReader


<cfscript>
    csvUrl = "http://yourdomain.com/sample.csv";
    csvData = [];

    // InputStreamReader
    streamUrl = CreateObject("
java","java.net.URL").init(csvUrl);
    streamReader = CreateObject("
java","java.io.InputStreamReader").init(streamUrl.openStream());

    // use JavaLoader to load OpenCSV
    paths = [ExpandPath("
/opencsv-2.2/deploy/opencsv-2.2.jar")];
    loader = CreateObject("
component", "javaloader.JavaLoader").init(paths);

    csvReader = loader.create("
au.com.bytecode.opencsv.CSVReader");
    csvReader.init(streamReader);
    csvData = csvReader.readAll();

    // release system resources
    csvReader.close();
    streamReader.close();
</cfscript>
<cfdump var="
#csvData#" />

CFDump Result

I've only scratched the surface of what OpenCSV can do for you by the way ... I'll leave it up to you on how to write CSV files and even dump out SQL tables to CSV with OpenCSV. It's pretty cool stuff!

Peace.

How to Remove WWW from the URL in Mura CMS with ColdFusion

Recently, a Mura CMS user asked how to remove the 'www' from the URL. So I thought I would whip up a quick post on how to do it.

  1. Login to the Admin and go to your 'Site Settings' (top-right on yellow toolbar).
  2. Select the site you wish to enforce this rule on.
  3. On the 'Basic' tab, make sure you have 'yourdomain.com' in the 'Domain' field.
  4. Also, make sure you list 'www.yourdomain.com' in the 'Domain Alias List' text area.
  5. Click 'Update'
  6. Now we'll edit a file that would probably be included on each page in your site such as \{siteid}\includes\themes\merced\templates\inc\html_head.cfm
  7. Copy and paste the code below into the top of the file that is located on each page:


<cfscript>
    myDomain = "yourPreferredDomain.com";
    domainIsCorrect = true;
    if ( getPageContext().getRequest().getServerName() neq myDomain ) {
        domainIsCorrect = false;
        urlstr = "http://" & myDomain & getPageContext().getRequest().getRequestURI();
        if ( len(trim(getPageContext().getRequest().getQueryString())) ) {
            urlstr = urlstr & "
?" & getPageContext().getRequest().getQueryString();
        };
    };
</cfscript>
<cfif not domainIsCorrect><cflocation url="
#urlstr#" addtoken="false" statuscode="301" /></cfif>

That's it! Enjoy.

Launched New Online Presence for Family Optical Centre Powered by ColdFusion + Mura CMS

Family Optical Centre, Inc. has officially launched their first ever online presence at www.familyopticalcentre.com. Family Optical Centre has been a part of the Rockford-area community for over forty-five years and currently operates three locations throughout the area. If you're in the market for some new frames and/or lenses, you might be interested in taking advantage of some of their Special Offers too.

The site is powered by Adobe® ColdFusion® and Microsoft® SQL Server with online content management provided via Mura CMS. Talented artist and designer Greg L. provided an elegant, yet simple design which I quickly and easily converted into HTML, CSS and Mura CMS templates.

Congratulations to the team at Family Optical Centre on your new online presence. Best wishes for continued success!

Family Optical Centre
Designer: Greg L. | Developer: Steve Withington

MuraMediaPlayer Plugin Released for ColdFusion-Powered Mura CMS

I was finally able to finish up my MuraMediaPlayer plugin for Mura CMS. This plugin uses JW Player™, the Internet's most popular and flexible media player. It supports playback of any format the Adobe Flash Player can handle (FLV, MP4, MP3 and AAC). It also supports RTMP, HTTP, live streaming, a wide range of settings and more.

This plugin is available in the Mura CMS App Store under plugins. Since the primary guts of the plugin are driven by my cfMediaPlayer project hosted on RIAForge (a ColdFusion wrapper of the JW Player™), I'm posting a copy of the license here just so there's no confusion.

License

By using MuraMediaPlayer, you agree to the 'non-commercial' license found at http://creativecommons.org/licenses/by-nc-sa/3.0/. For corporate use or if you're planning to generate revenue from your site (e.g., by running advertisements on the page, selling anything, etc.) you will need to buy a license for JW Player™. To obtain a commercial license of the JW Player™, please visit http://longtailvideo.com/players/jw-flv-player/commercial-license/

Installation

Installing the plugin is pretty simple. I've created a brief video tutorial and also included an outline of some simple steps to follow:

Installing MuraMediaPlayer

  1. Download the plugin from the Mura CMS App Store's plugins section
  2. Note the location of the 'muramediaplayer.zip' file that you downloaded
  3. Log in to your Mura CMS Admin area
  4. Click 'Site Settings' found on the top-right portion of the screen on the yellow bar
  5. Select the 'Plugins' tab
  6. 'Browse' to the location of the 'muramediaplayer.zip' file and select it
  7. Click 'Deploy' and the 'Plugin Settings' form should appear
  8. If you want to change the 'Plugin Name,' feel free to do so
  9. You can simply leave the 'Load Priority' alone or change it to anything you want to be if you have other plugins that require loading ahead of it
  10. If you're Mura CMS install is using Amazon S3 for file storage and you've set up an Amazon CloudFront, you can enter the 'Cloud URL.' Otherwise, leave it blank.
  11. If you're Mura CMS install is using Amazon S3 for file storage, you have an Amazon CloudFront set up and you've setup a Streaming Distribution to deliver content to end users in real time, you can enter the 'Streaming URL.' Otherwise, leave it blank.
  12. Under 'Site Assignments,' select the site(s) you wish to enable the plugin to run on.
  13. Click 'Update' when finished.
  14. That's it! You're ready to create MuraMediaPlayer pages and/or use a new [mura] tag method that is now available to you.

Please visit Amazon for more information about their S3 and CloudFront services.

Usage/Instructions

Detailed instructions for using the plugin are available at http://www.getmura.com/index.cfm/app-store/plugins/muramediaplayer/documentation/. In addition, instructions can be found after you install the plugin simply by logging into the Admin area, click 'Plugins' (or go to 'Site Settings', then select 'Plugins' tab), then click the 'MuraMediaPlayer' link.

How to Strip/Remove the SiteID From the URL in Mura CMS

The first step in removing the SiteID from the URL in Mura CMS is to edit the file located at /config/settings.ini.cfm. Find the 'siteidinurls' attribute and set it to read siteidinurls=0. If you don't see this attribute, you might be using an older version of Mura, and you should probably upgrade your install. If for some reason, you cannot upgrade your install, then read this Mura blog posting titled Removing the SiteID from URLs in Mura.

Once this is done, you're usually pretty good to go. However, you can still actually navigate to your pages with the SiteID in the URL. In fact, when you preview your site from the Admin area, it usually includes the SiteID and someone expressed a desire to "fix" this for search engine optimzation (SEO), analytics, etc.

This is actually pretty easy to do by adding a few lines of code to your Mura CMS templates. The easiest thing to do would be to probably just add this to your 'html_head.cfm' file if you use it.


<cfscript>
    hasSiteIDinURL = false;
    if ( not application.configBean.getSiteIDinURLs() ) {
        urlstr = getPageContext().getRequest().getRequestURL();
        idx = listFindNoCase(getPageContext().getRequest().getRequestURL(), event.getSite().getSiteID(), '/');
        if ( idx gt 0 ) {
            hasSiteIDinURL = true;
            urlstr = listDeleteAt(urlstr, idx, '/');
            if ( len(trim(cgi.query_string)) ) {
                urlstr = urlstr & '?' & cgi.query_string;
            };
        };
    };
</cfscript>
<cfif hasSiteIDinURL><cflocation url="#urlstr#" addtoken="false" statuscode="301" /></cfif>

Hope this helps!

Mura CMS Full Day Training Course on April 21, 2010

How would you like to spend a full day with the folks who created Mura CMS from the ground up? Are you in or around the Minneapolis, Minnesota region ... and if not, can you get there by April 21, 2010?

Well, Team Mura recently announced they would be offering an in-depth, full-day "Programmers Guide to Mura CMS" on Wednesday, April 21st, 2010. This is technically a "cf.Objective() 2010 Pre-Conference" event, however, you don't have to attend the full conference to take advantage of this great opportunity.

Here are a few of the topics that will be covered:

  • Programmatically working with content in Mura CMS
  • Working with Mura CMS objects
  • Understanding the Mura CMS event model
  • Integrating Existing or 3rd Party Applications
  • Building Mura CMS Plugins
  • Extending and customizing Mura CMS while staying on the upgrade path

This full day course will be limited to the first 20 students and costs only $500. Considering the number of Team Mura developers that will be on hand, you probably won't be able to find a better student to instructor ratio. Oh, and for what it's worth, I'll be there too!

Before you say no to this awesome deal, I ask you to take something else into consideration. Have you ever attended a training event only to go back to your office, sit at your desk and not truly applied the newly learned knowledge? If you are a web site developer and have either looked at, used Mura CMS, or are even a seasoned Mura CMS developer and want to build sites more efficiently while allowing your clients the ability to manage their own content ... then you will most definitely be able to bring what you've learned back to your office and apply it to your job the very next day. Yes, I mean that if you attend on Wednesday, by Thursday you will be more productive, period.

Again, only the first 20 students will be accepted, so register now before it's too late!

Using jQuery to Pass an Index Value to a Shadowbox.js Gallery

I ran into a bit of a hair-pulling incident recently and I really couldn't find any help on the web with this one. So I thought I'd share my frustration and the solution I came up with in case anyone else runs into a similar problem ... or heck, maybe you've got a better solution for me. In short, I needed to be able to pass an index value to Shadowbox.js when a gallery was launched so that it would begin at the desired position. However, I personally find it more interesting to understand the evoution of the problem and the eventual solution. If you're not like me, feel free to jump down to the jQuery and HTML code below.

The Problem Challenge

Well, this all started out when one of my clients wanted one of those fancy-dancy "hover-over-a-group-of-thumbnails-and-swap-a-medium-sized-image" thing-a-ma-bobs. Trust me, this was not the challenge ... using a few lines of jQuery and fancy-dancy-be-done.

Then, after looking things over a bit, the client wanted to be able to click on the thumbnail and open a modal window of the original, much larger, image. Again, no worries ... using a bit of Shadowbox.js magic, and client-be-happy.

Finally, after reviewing my jQuery/Shadowbox/programming magic, the client was happy ... but they wanted one more thing ... to be able to click on the medium-sized image and have it launch a modal window of the original, much larger, image too. So, after a little extra thought and tweaking around, I got it working ... well, sort of.

Here's the Deal

Everything worked just fine except for the fact that if I enabled the 'continuous' attribute so that people could click "Next" and "Previous" links, something odd occurred.

If I clicked a thumbnail, the Shadowbox opened and did its thing as expected. If there were four (4) image thumbnails, then when the modal window opened, the "Next" and "Previous" links would cycle through four (4) images. But when I clicked the medium-sized image, the larger version of the image would appear twice in the modal window for a total of five (5) images.

Anyway, I realized fairly quickly that by default, Shadowbox creates a cached array of things such as all links with a 'rel' attribute of 'shadowbox' when the page loads. You can easily override this feature in the Shadowbox init() method by setting the 'skipSetup' attribute to true. But that's not what I really needed, or wanted, to do. I already had the thumbnails working and just wanted to get the 'Medium' sized image to also open the Shadowbox.

The My Solution

Ultimately, I needed a way to keep track of the index of each Shadowbox link element so that I could use it when calling a Shadowbox function I hadn't used before called "Shadowbox.open()." I knew there just had to be a way of passing the index value to Shadowbox so that way when the modal window would open, it would just cue up to the cached index in Shadowbox.

So I created a custom attribute for the "a" link of the thumbnail images called "idx" and since I was already outputting the thumbnails from a query, this was pretty easy to do. However, since I was using a ColdFusion loop to output an array of the images, I couldn't just use the index value of the loop since ColdFusion arrays start at 1 while just about every other programming language, including JavaScript, have their arrays start at zero (0). So for you ColdFusion peeps, just remember you'll want to add your own "counter" variable that starts at zero and then increment it at the end of each iteration of the loop.

Once I had an attribute I could access using jQuery, I knew I was in business. The next thing I needed to find out was how to pass this index value to Shadowbox. Again, nothing on the web helped me out here. I did stumble across someone's post in the Shadowbox forum about how they modified the source code to accommodate something like this, but I chose not to go that route. In addition, this was a site using Mura CMS and I really didn't want to make any alterations to any included third-party code if I really didn't have too.

After studying the Shadowbox source code for a bit, I found this line of code in the Shadowbox.open() method (around line 2122):


// is it a link?
if(isLink(obj)){
    if(typeof obj.shadowboxCacheKey == 'undefined' || typeof cache[obj.shadowboxCacheKey] == 'undefined'){
        // link element that hasn't been set up before
        // create an object on-the-fly
        obj = this.buildCacheObj(obj, opts);
    }else{
        // link element that has been set up before, get from cache
        obj = cache[obj.shadowboxCacheKey];
    }
}

Notice the "shadowboxCacheKey" bit? Bingo! Now I knew all I needed to do was tweak my jQuery code to add this sweet little attribute to the link and then call the Shadowbox.open() method along with some options to tell Shadowbox which gallery I wanted to use and at what index to begin! Can you tell I was a little excited?

So instead of continuing to bore the crap out of you, I'll just go ahead and show you what I came up with.

The jQuery


$(document).ready(function() {
    $(".imageThumb").hover(
        function() { // handlerIn
            var mediumImage = $(this).find('a').attr('medium');
            var imgLink = $(this).find('a').attr('href');
            // this holds the 'Shadowbox' cacheKey index value!
            var imgIndex = $(this).find('a').attr('idx');
            $('#swapImg').attr({src:mediumImage}).fadeIn(800);
            $('#swapLink').attr({href:imgLink,idx:imgIndex});
            return false;
        }
    );

    $("#featuredImage >
a#swapLink").click(function(event) {
        event.preventDefault();
        // grab the 'Shadowbox' cacheKey index value
        var idx = $('#featuredImage').find('a').attr('idx');
        // now add the index key to the link so that when we call open, it knows this link already exists
        this.shadowboxCacheKey = idx;
        Shadowbox.open(this,{gallery:"products",continuous:true});
    });

});

The HTML


<div id="imageThumbs">
    <div class="imageThumb"><a rel="shadowbox[products];options={continuous:true};" idx="0" href="img1.jpg" title="" medium="img1-med.jpg"><img src="img1-thumb.jpg" alt="" width="70" height="70" /></a></div>
    <div class="imageThumb"><a rel="shadowbox[products];options={continuous:true};" idx="1" href="img2.jpg" title="" medium="img2-med.jpg"><img src="img2-thumb.jpg" alt="" width="70" height="70" /></a></div>
    <div class="imageThumb"><a rel="shadowbox[products];options={continuous:true};" idx="2" href="img3.jpg" title="" medium="img3-med.jpg"><img src="img3-thumb.jpg" alt="" width="70" height="70" /></a></div>
    <div class="imageThumb"><a rel="shadowbox[products];options={continuous:true};" idx="3" href="img4.jpg" title="" medium="img4-med.jpg"><img src="img4-thumb.jpg" alt="" width="70" height="70" /></a></div>
</div>
<div id="productImages">
    <div id="featuredImage"><a idx="0" id="swapLink" href="img1.jpg" ><img id="swapImg" src="img1-med.jpg" border="0" alt="" /></a></div>
</div>

That's it! I hope this helps someone else and saves some hair pulling. Enjoy!

Issue with Mura CMS, ColdFusion, ISAPI and IIS6

Awhile back I ran into an issue installing Mura CMS on a dedicated Windows server running, ColdFusion, ISAPI and IIS6. The issue wasn't blatantly obvious at first because Mura would install just fine and the home page would show up so I thought everything was just fine. However, once I began adding pages to the site and then attempted to view those pages, they wouldn't show up. I would get the ever popular 'The page cannot be found' screen. The first thing I did was check some other Mura sites I had already had installed on the server and each one of them had the same issue. This was extremely odd to me because all of my Mura sites had worked just fine before and I never noticed any problems.

So after tinkering around a little I began thinking about any software I had installed recently that might even remotely affect what was going on. Well, the only thing I could think of was ISAPI. I had just installed it with the previous day or so and wasn't really using ISAPI yet. So I uninstalled it, then checked my sites and they all seemed to work just fine. Well, that's great, isn't it? Sure, if you don't really use or need ISAPI, which was my case at the time so I just went about my business and never dug any further into the issue.

So, a few months went by and some developers who were in the process of evaluating Mura shot me a message asking for a little direction on a problem. "We have Mura up, but cannot go to sub pages. I think it is a SEO URL thing that IIS6 is not handling correctly ..." and they attached a couple of screen shots for me to look at. It took me a minute to remember, but I asked them if they had ISAPI installed. Sure enough, they did. So I proceeded to let them know if my recent experience, but wasn't able to help them really solve the problem ... because see, they actually used ISAPI and needed to have it play nicely with Mura.

A short time later, one of the developers had a "eureka!" moment. In hopes of guiding any other people running into this problem, I've opted to post his entire response below. Many thanks (and congrats) to Ken Payne for solving this problem!

Steve,

I just figured out our iis6/cf8 404 problem and I thought you might like to know what its was.

By default CF8 is not SES enabled.  I saw how to correct this early on in my investigation, by uncommenting the appropriate entries in the web.xml file.  This had no apparent effect and we assumed it wasn't even hitting CF anyway since it was a IIS 404 error.  So after your hint that it may be ISAPI we edited IIS and did a restart and voila the SES URL's now worked.  On 1 but not on the other 2 installs.  I hadn't restarted the other 2 cf instances after editing their web.xml... 

So after monkeying with restarting IIS and the other CF instances they magically worked at some point.  Enter the new developer with his own CF instance and we have the same problem.  It didn't take me long to puzzle it out by dumb luck on my first try.

So the correct sequence is:

  • Edit web.xml to enable ses
  • Restart the CF instance
  • Restart IIS
  • Done!

So simple once I see what's going on.   IIS was smart enough to know that CF didn't have a servlet for handle the ses url so it just didn't pass it.  This was not obvious since at one point it did indeed pass it on during my testing when I re-commented the ses servlet declarations and tried accessing with ses url.  But of course I had not restarted IIS yet so it thought CF could handle it etc.

Hope that made sense.

More Entries

© 2010, Stephen J. Withington, Jr.  |  BlogCFC was created by Raymond Camden – Version 5.9.004

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