For some time now I’ve been planning on doing a major overhaul of the DMCInsights.com Web site. I have many goals for the revised site:
- A simpler, cleaner design, better for presenting long blog posts and code
- Integration of the blog into the main site
- Better promotion of my books
Over the past year I’ve flagged designs and designers that appeal to me, in the thought that I’d use a custom design for the site. As a last bit of research, before hiring a designer, I looked at available WordPress themes (WordPress is perfect for me as a content management tool). What I found, and what I’m using, is the Carrington WordPress Framework, and I’m so happy that I did.What struck me about the Carrington WordPress theme at first is how clean it is. Aside from converting the two column sidebar into a single column, and adjusting the size of the content area a bit (increasing it and decreasing the width of the sidebar), the theme works well, right out of the box, for what I wanted. But that doesn’t really set Carrington apart from the thousands of available WordPress themes. What’s unique about Carrington is that it’s a framework, although not in the way I normally think of frameworks. Basically it comes down to this: it’s crazy easy to dynamically extend a theme thanks to the Carrington concept of “contexts”.
A basic WordPress theme has a couple dozen files that get pulled together to make the complete page: a header, the content area, the sidebar, the comments area, etc. Carrington has this, too, and you can edit any of those files to change the layout. Carrington adds to this multiple-file organization scheme by supporting multiple include-able files. You can take most of the distinguishing attributes of a site’s content—its categories, tags, author, etc.—to create a “context” file.
Tip: Of course you can use and customize widgets to change the layout as a whole. Carrington also lets you customize some of the primary CSS on the fly, using the WordPress admin area.
For example, individual comments are displayed by including the comment/comment-default.php file. If I want to format my own comments differently than anyone else’s, I just make a copy of that file and edit it as I want. This new file (in my case) would be named comment/user-larry.php file. When a post is loaded which has comments, if the user associated with any of the comments has the name “Larry”, the custom file will be automatically included instead of the default file. The only thing that’s required is the creation of the replacement file with the appropriate file name.
As another example, the new site will highlight one or more of my books for certain posts, by displaying the book’s cover in the sidebar. I was thinking I’d have to write a widget to do this, but Carrington can do it all easily. I just create a file named sidebar/cat-php.php and it will be used to display the sidebar for any post that’s in the PHP category.
For pages in WordPress, which are slightly different than posts, I can make use of the “meta” attribute to create custom files. For example, on the pages for a certain book, I want to show that book in the sidebar. To do that, I just add a “meta” attribute to the page with a name of “book” and a value of “phpmysql” or whatever. Then I create sidebar/meta-book-phpmysql.php. And that’s it!
It took a while to grasp the whole concept, and the Carrington documentation is meager, but once I figured out how the system worked, it became blindingly simple and fast to customize the look and behavior of the site on the fly, which is exactly what I needed. This process does end up creating redundant code (for example, several different sidebar files), so you really want to get the basic layout nailed down before creating custom includes. But this approach really beats editing each file to add all sorts of conditionals based upon user names, categories, tags, meta information, and more.
I’ve got all the basic functionality working as I’d like it to, now I’m just finishing all the content. I’m hoping to have the revamped version of this site online by the end of the month.