Friday, January 15, 2010

Perch: A Lightweight, Inside-Out Content Management System

In a typical Content Management System, like WordPress or Joomla, the CMS itself is the one that runs the show. It stores all the content, and when asked, renders it for the user. This is usually a Good Thing, as it implements a whole lot of functionality that programmers would have had to write in the past. Now, the CMS does the heavy lifting, content editors write the content, and programmers can swoop in and write small plugins that run inside of the CMS's universe. For a content based site, it's an ideal setup.

But what if you don't have a content based site? What if you have a web app, and the marketing department would like to be able to edit the content? It sounds like a job for CMS, but you'll run into two main issues: (1) in order to fit into the CMS's word, you'll need to effectively embed your application inside of it (or perform some other contortions to use it) and (2) in order to be able to edit a few paragraphs of text and there, you'll end up incurring the cost of an entire CMS framework. Which in the case of WordPress or Joomla, can lead to performance issues.

What's a programmer to do?

An Inside-Out Solution

This is the dilemma I've faced in the past, and again this morning. Always on the lookout for a better solution, I managed to Google my way to Perch. Perch is essentially an inside-out solution: instead of assuming that the CMS runs the show, it assumes you've already got a working application. Instead of being the boss, it wants to just pitch in where it can. Which in its case, means tweaking your code anywhere you want custom text to show up, ever so slightly.

Integrating in Perch is as easy as saying:

 <? require_once('perch/runtime.php'); ?>
 ...your page's code...
 <? perch_content('Home Page')? >
 ...more code...

Once you've done this, you've just about made your web application CMS accessible. Now you need to log into the Perch back end UI, and tell Perch what kind of content should live there (1 line of text, multiple lines, an image, or something fancier). Once you've done that, you can tell the folks in marketing to log into the Perch UI and edit the content as frequently as they want.

My description doesn't really do it justice, I'd suggest taking a few minutes and watching the intro video.

As you can see, Perch is not only operates inversely than most CMS systems, it's also really lightweight. It's not free, but at $60.00, it's pretty dang close.

Lots To Like

I've only been playing with Perch for the last couple hours, but I've already found a bunch of features I really like about it:

It gets the workflow right. The dual roles (admin and editors) is simple, and powerful. The people who need to change content can do so, without having to worry about making system changes they shouldn't.

It's programmer friendly. The call to perch_content is flexible enough that you can use it in more than the simplistic context. For example, you can include the following at the top of every page:

  perch_content(get_current_page_name() . " Meta Tags");

This will automatically define Home Meta Tags, About Meta Tags and any other page that is called. There's no need to hand code any the pages.

I like that you can get perch_content to return the text instead of editing it. It allows you to say something like:

  $meta = perch_content(get_current_page_name() . " Meta Tags", true);
  if(preg_match("/Undefined content/", $meta)) {
     $meta = default_meta_tags();
  }

Templates allow for more sophisticated text replacements. When you define a perch_content area, you associate a template with it. This template forces the content editors to enter particular information (say: a title and body), and then says how those entered items should be rendered (say: within <h1> and <div> tags). Combine this with the fact that you can mark items as being shared across all pages, and have multiple entries, and you end up with some really cool functionality.

For example, I defined the Sidebar template as:

<li>
  <h2><perch:content id="title" type="text" label="Title" required="true"/></h2>
  <p><perch:content id="body" html="true" type="textarea" label="Body"/></p>
</li>

Inside of my web app, I embedded a call to the sidebar as:

<ul>
 <? perch_content('Main Sidebar'); ?>
</ul>

Inside of the Perch UI, I marked the Main Sidebar as shared and supporting multiple items. A content editor can then add as many text items to the sidebar as he'd like (including HTML), so this includes YouTube videos and other embedded content.

The CMS content is generated once and served from static files. This means that adding Perch CMS functionality won't impact your performance in meaningful way. It does mean that template changes aren't shown to you on the fly, but this seems like a small price to pay for rock solid performance.

It's Keeper

As you can see, I'm pretty much sold on it. Of course, I'll really know how well it works if I end up using it on a production project or two. But so far, I'm sold.

10 comments:

  1. I'm would like to see more of your $meta solution? How is this working?

    ReplyDelete
  2. Christian -

    So far I have embedded Perch into two sites, and while I haven't used it for meta tags yet, I've had success using it for regular on page content.

    Are there a specific questions I could perhaps answer?

    -Ben

    ReplyDelete
  3. Helpful post. How did you find it?

    ReplyDelete
  4. Farheena, what do you mean? How did I find Perch? Google. How did I find this article? I wrote it.

    ReplyDelete
  5. Thanks for the posts we are the professional web design and development company offering an array of services like template customization, web designing, CMS solutions, eCommerce solutions, Search engine optimization and Internet marketing.
    Cms Services and Web Development

    ReplyDelete
  6. Thanks for the information, we will add this story to our blog, as we have a audience in this sector that loves reading like this” scms services

    ReplyDelete
  7. Hi Ben,

    Since you've liked Perch, perhaps you'll also find CouchCMS (http://www.couchcms.com/) equally useful.

    It can be retrofitted within existing static sites and accomplishes fairly complex things by using only XHTML like tags. No PHP required at all, which makes it ideal for web designers.

    Perhaps you'd like to review it too.

    ReplyDelete
  8. kksidd -

    Thanks for the tip. Next time I have a client who needs a lightweight CMS, I'll check it out.

    -Ben

    ReplyDelete
  9. Do you know if it's possible to implement Perch over a Joomla website?

    ReplyDelete
  10. Re: Perch over Joomla

    I would think this would work. I've used Perch with other sites that maintain a database connection and it doesn't seem to interfere with it.

    The only gotchas I've run into are: (1) you need to make sure the perch DB lives inside the same database that the site (Joomla) does, or it may end up disconnecting you from the site. (2) perch has a nasty habit of forcing the timezone to GMT which may hose you up.

    The last point may have been corrected in more recent versions of Perch.

    The bigger question is probably: why would need perch if you've got the full CMS of Joomla. But, perhaps you have a good reason.

    ReplyDelete

LinkWithin

Related Posts with Thumbnails