Posts Tagged ‘CMS’

Masters of the Universe – A Web Systems Suite

He-Man-Movie-To-Start-Fresh-At-New-StudioOkay so this is really fun. Just over four years ago I was working at a popular mortgage company as a back-end Tech Lead and was tasked with developing a PHP web framework to replace the dated and abominable system they currently had in place. Their current “framework” was like the ugly bastard child of an MVC with grade three burns. In other words it was total shit (all these years later and I still seem to harbor a great hate for it). The web had been advancing quite nicely and we were now looking at the birth of Web 2.0, so not only was it a misery for us developers to code in the current system, but it had now become a hindrance on what we were able to accomplish. So management finally understood the necessity to invest in a new system and I was charged with leading it’s development, I was finally able to realize a vision for a framework I’d been dreaming up for a while.

The first step of course was to come up with a cool name for the framework. After much brainstorming with the front-end Tech Lead (who was the co-creator of the framework) we finally came up with a name we both agreed on – Skeletor – not only a powerful villain from one of my favorite childhood toy franchises, but the name just seemed so damn appropriate for a framework. I was super excited with the name and the project, and I wanted everyone else to get on board and be as excited as I was. I also had the vision that the framework would belong to a web suite and comprise of various user interfaces to manage things like the URL catalog, error reporting, and debugging.

So the following is the very first piece of work I did for the project. The document was put together before the project was completely sold to management and definitely helped seal the deal. I also had the requirement to teach the rest of the team the fundamentals of OO programming and MVC frameworks. So my idea here was that each member of the team would get a character from the MOTU world, which represented a module within the framework, and they would have to become that character and learn everything about the purpose of that character, and understand it well enough to present it to the rest of the team, and eventually develop-out their module. In the end it was only two of us that were assigned to developing the framework, which we did and we did well, and that same framework now serves up over a half a dozen websites with over five million page impressions a month. So this is just a mock-up for something that never really paned out as planed, in the end we never really fleshed out and finished what I was attempting here, but even still I think I came up with a really fresh approach to teaching the concepts of OO development, or teaching anything for that matter, and to this day I still look back and try to match that same vision I had then with the work I do now. Enjoy!


A Web Systems Suite


The web systems suite comprises of everything involved in the website process:

  • Framework
  • Framework Objects
  • CMS Application Interface
SKELETOR – The Framework

The framework for the web applications. All applications live within an instance of the framework. It consists of libraries, classes and run-time infrastructure.

  • Logical and concise directory structure
  • Extends PEAR
I HAVE THE POWER – Master File

The master file for the SKELETOR framework. Mod rewrite points to this.

  • Controls environment and global settings
  • Initializes common global objects
  • Routes, dispatches and renders the browser call
QUEEN MARLENA – The Model

The model defines the properties of an object.

ETERNIA – The View

The view contains all the output for the page call, with defined placeholders for logical driven content. An object may have multiple views.

KING RANDOR – The Controller

The controller contains the default behaviour and helper classes of an object. All Skeletor objects extend the Skeletor controller.

EVIL-LYN – The Error Handler

The error handler takes care of where to log, and how to react to an error.

TRAP JAW – The Database Abstraction Layer

The database abstraction layer sits between the framework and the databases and handles all queries and results.

MAN-AT-ARMS – The Security Layer

The security layer controls access and permissions for the user.

BATTLE CAT – The Content Catalog

The content catalog is both a CMS interface and a stored representation the its data. It defines what view and model a URL should dispatch.

RAM MAN – The Forms Catalog

The forms catalog is a CMS interface used to build the web forms and define how the captured data is stored.

CASTLE GRAYSKULL – The Session Handler

The session handler controls how session data is stored (e.g. serializing objects) and where it is stored to (e.g. written to the file system or a database).

STRATOR – Redirect Handler

The redirect object handles how all the various possible redirect types are handled. It will consult with the content catalog to know how to handle a URL redirect (301 moved permanently, 302 temporarily redirected, etc.)

TEELA – Form Handler

The form handler consults with the Forms Catalog

PANTHOR – The Request Dispatcher

Consults the catalogue hash map and calls the appropriate object.

SORCERESS – The AJAX Handler

Enables a page to speak telepathically with the server.

SNAKE MOUNTAIN – The Skeletor Control Center

GUI to configure and control many core aspects of the framework.

  • Generates new applications
  • Control user access
  • Control error handling
TRI-KLOPS – The Search API

The search appliance interface.

ORKO – Documentation System

This represents the importance of both automatically generated code documents (PHPDocs), and manually generated user-friendly documentation (HOWTOs).
Tuesday, October 6th, 2009

Blog Relaunch

So I finally managed to find the time to relaunch this blog. When I first started the blog it was somewhat of an experiment so I didn’t spend much effort on its design, but unlike other failed blogs I’d started over the years I’ve really been enjoying writing these posts and I think this time around it’s got some staying power. This relaunch is really intertwined with my online rebrand I’ve been talking about lately, this blog plays a big part in my online image and it was important that I spend the time to focus on fixing its issues.

So the biggest areas I wanted to address were:

Domain Name

My old domain ‘blog.londonstreetlife.com’ had many things wrong with it, but mainly it was just too damn long.  The hows and whys I picked this domain are obviously very closely related to my rebrand so I’ll talk about it in another post, but this new domain is half as long and I’m really liking how it looks in the browser address bar.  In fact it’s so short i can pair it with my own URL shortener (instead of using bit.ly, for example) which will only help improve my online brand in the long run.

Switch from Blogger to Wordpress

For all the work I’ve been doing with Wordpress this past year and my subsequent posts on the subject, I’ve felt for a long time I really should be blogging on that platform.  I have nothing against Blogger or any similar web tool, it’s been great to me and I don’t see the need to host the blog myself as long as it provides me with everything I need and doesn’t limit me in any way.  However I have really been feeling the strain lately with Blogger, too many missing features, SEO failings, and little tweaks I am not able to make.  Now I’m on Wordpress and am my own host and I can really go to town with this thing!  Like a kid in a candy store I’m having a lot of fun practicing what I have been preaching and I even built my own plugin which I will be cleaning up and making publicly available soon.

Design

The new design is the most prevolent update as it really changes the whole feel of the blog.  Whilst the switch from Blogger to Wordpress could be completely transparent to the user, and the domain name change might not even be noticed by a user coming in via a shortened link, there’s definitely no escape from noticing the redesign.  I don’t want to get too into the color scheme I’ve gone with as it’s part of my brand color palette that I’ve been developing over the last month, and again I’ll be talking about that in another post.  It’s not yet the finished product I’m sure, I’ll tweak as I go, but time is short for me these days and I’ve found that eventually there comes a point where I just have to pull the trigger or I’ll never get anything done.  It is worth mentioning that whilst I do prefer dark text on a light background for readability purposes I really wanted to bring forth more of my personality into the design, so my words don’t just represent me, but also just by being here you already know a little bit of who I am.  I’m really happy with the color scheme, it is totally me, and it works really well for my portfolio site (in development) where impression is as important as content, but for here where content is king I might find along the way that the sacrifice in readability is too great for a blog and switch it up and around a bit, make it a little easier on the eyes.  I dunno, what do you think?  It’s really up to you guys!

It’s worth taking a moment to talk about my old design and how in a way it was sort of an anti-design, I’m not referring to the art movement but the fact that it was meant to look like I hadn’t spent a lot of time designing it (cos I hadn’t).  But also when I first started the blog I didn’t know where it was going to go or if it would even last so I really needed it to develop a personality before I could style it.  So for old times sake, one last time and forever remembered here, RIP old blog:

londonstreetlifetheblog

Blog Title

And finally the blog title, I’ve been seeing some of my posts come up in Stumble Upon and they’ve been coming across kind of silly – Blogger published the blog name first and then the post title and I couldn’t figure out a way to reverse this setting, so every post of mine that made it into Stumble Upon just said my crap blog name and didn’t give a clue as to what the article was even about.  That’s when I really started to realize that if I want the web to take my blog seriously then I’d better do it first myself.  Before the the title was just ‘my name the blog’, as in ‘londonstreetlife the blog’, which basically ran along the same idea as my anti-design concept above, and again I didn’t know where it was gonna go or how long it would last so I didn’t spend the time thinking up a cool name, and in the end it never eally had one.  The new name ‘Pixels from the Edge’ I think works really well, it kind of means a lot of things at once and they all apply.  I wanted the name to reflect the creative-technology hybrid thing I got going on and is mainly what I talk about in this blog, and I think it does that very nicely.  My lovely wife helped me come up with the name, so mad props to her!  And the more I think about it the happier I am with it.

So what do you think folks, turned out any good?

Tuesday, August 18th, 2009

Customizing Wordpress as a CMS finishing touches

My last couple of posts I’ve talked about how to customize Wordpress to create your own theme and templates. As I talked about in this post I feel that Wordpress is a hugely powerful CMS admin system but falls behind with its front-end publishing capabilities. I don’t like how it publishes the HTML and in this post I will give some hints as to how to completely abandon the Wordpress front-end for your own.

Custom Permalinks
By default all pages are created as something like ‘http://www.mysite.com/?p=14′. But Wordpress has it’s own built-in URL parser and router allowing us to make pretty URLs. Click ‘Settings->Permalinks’ in the left sidebar and select the ‘Month and name’ radio button and hit save (don’t worry about the other options, they really only affect the “posts” URL structure and we’re only concentrating on “pages” here).

It creates an ‘.htaccess’ file in the web root, if Apache doesn’t have permission to create this file then you can create it yourself with the following:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Basically every file that doesn’t exist (media, css, js, etc. files that physically exist bypass the rule) gets sent to the index.php file which does a URL lookup and routes to the correct template.

You can now go and look at a custom page you’ve made and see it has a beautified URL as a Permalink.

Custom Header and Footer
The default Wordpress header and footer does a lot of automatic work. In order to free your code from this I recommend creating you own header and footer. Any functionality that the header and footer contains that you want to keep can be ported over as you need it.

In your theme folder create your own header.php and footer.php files. It’s probably a good idea to save a backup first (even though you’ll probably already have the whole thing backed-up from when you created your own theme, and then get rid of everything in the files you don’t want. For example when I first started experimenting I kept all the boiler plate stuff and ditched the automatic navigation generation and sidebar code. Start with the minimum and work things back in from your template as you need them, if you feel you need them, personally I rewrote everything back in.

Once you understand what you’re doing here you can drop the whole header and footer approach and use a templating engine such as Sigma (which I’ve favored for some time).

Custom Homepage
The final move is to set the homepage as something other that the blog. This is the final key in freeing up Wordpress from being a blog tool dependent on the default code to becoming, well anything you want from a website, backed by a powerful CMS. Of course you will also always have the option to quickly and easily implement a powerful blogging system into your site, but the point is the blog doesn’t actually have to be your site.

In your admin panel create a new page with the title ‘HOMEPAGE’, I recommend to first create a homepage template because a homepage is never like anything else. Once you have that page published navigate to ‘Settings->Reading’ and under the first option ‘Front page displays’ select the second radio button ‘A static page (select below)’, and in the drop-down find the ‘HOMEPAGE’ page you just created, and save your changes.

That’s it, you’re now free to go crazy with your website design and code yet still harness the power that the Wordpress CMS yields! And don’t forget if you want to have a blog in your website, now or in the future, you already have all the tools you could want.

This is part of an ongoing series of posts I am publishing talking about how to use Wordpress as a custom CMS.

Thursday, April 16th, 2009

Create a custom template in Wordpess

1. Open up a new file and add the following:

<?php
/*
Template Name: My Template
*/
?>

2. Save the file in your theme folder with the name of your new template, the filename doesn’t have to be an exact match for the template name, e.g. ‘mytemplate.php’.

3. In the admin panel create a new page. Give it a title, type in some content, and then in the right sidebar under ‘Attributes’, find your new template in the drop down and select it, and publish the page.

4. When you view your new page on your sites front-end you’ll see a totally blank page. This is good and means it’s worked as we’ve not told the template to do anything yet.

5. Go back to your template file and update it to match the following:

<?php
/*
Template Name: My Template
*/
get_header();

get_footer();
?>

6. Now when you refresh your new page you’ll see the header and footer are now incorporated:

7. That’s great but the content from the CMS is still missing. Add the following into the template file between the get_header() and get_footer() calls, save it and refresh the page:

$thisPage=query_posts("pagename=".$_SERVER["PATH_INFO"]);
echo $thisPage[0]->post_content;

That’s it, you’ve just created your own template! You can now continue to develop out your new template and create more pages using that template, and create more templates.

This is part of an ongoing series of posts I am publishing talking about how to use Wordpress as a custom CMS.

Friday, April 3rd, 2009

Create a custom Wordpress theme in one minute

Creating a custom Wordpress theme is damn easy. So easy in fact that when I was originally researching how to do this I didn’t find anything out there that relayed exactly how easy it is. You can find detailed instructions at the official Wordpress documentation, but if you are an experienced web developer and php coder this will give everything you need to immediately hit the ground running.

Assuming you have a working version of Wordpress:

1. Go into your ‘/wp-content/themes/’ folder

2. Copy the ‘classic’ folder and rename it to something that will represent your site (use underscores to separate words and stick with alphabetic characters only – see comment from Ron Fredericks below)

3. In the new folder you just created open the file called ’style.css’

4. In the top of that css file edit the sections within the /* commented out area */. Update ‘Theme Name’, ‘Theme URI’, ‘Description’, ‘Version’, ‘Author’, and ‘tags’ appropriately with your new themes information. (If you can’t think of everything right now don’t worry you can always come back later and change it.)

/*
Theme Name: My Theme
Theme URI: http://www.londonstreetlife.com/
Description: My custom theme.
Version: 1.0
Author: Richard Perry
Author URI: http://blog.londonstreetlife.com/
Tags: Simple gray, two column
*/

5. Create a 300×225 pixels png image with a screenshot of your site, name it “screenshot.png” and overwrite the current one in your theme folder. If you don’t have the design done yet then create an FPO image for the time being, or you can use the one I already made below:

6. Now the fun part. Log into your Wordpress admin section and click Appearance->Themes in the side menu. Now you’re in the themes admin section and you should see the theme you’ve just created under the ‘Available Themes’

7. Clicking either the thumbnail or theme title of your theme will bring up a screen with a demo of your new themes homepage (obviously you haven’t changed anything yet so it will still look life the classic theme.)

8. Hit the ‘Activate’ link top right to set this as your wordpress theme.

That’s it, you’ve just created your own theme! Now you can start making changes to the ’style.css’ file to make it your own.

This is part of an ongoing series of posts I am publishing talking about how to use Wordpress as a custom CMS.

Monday, March 30th, 2009

Using WordPress as a custom CMS

I recently had a crash course in WordPress when I had to build a very custom website from scratch in two weeks from start to finish. It needed to be WordPress because this site will contain a blog that will be handed off to a third party to maintain, and WordPress is arguably the industry standards for blogging software. I wasn’t overly familiar with WordPress, I’d setup a blog or two in my time, but never anything as complex as building a custom theme or plugin. But I basically knew everything I needed to do was possible, I’d read up on being able to create custom themes and plugins and I felt quite confident that I could get done everything I needed to. What I didn’t know really was how I was going to do it, or how it was going to run as a CMS once launched. In the end I was surprised at how easy some things were to implement, and frustrated at the lack of what I would consider common tools.

What I realized pretty quickly were two things:-

  1. The Administration Panel is kick-ass, it’s beautiful to look at and use and takes care of all the administration dirty work you’d have to do if you were writing from scratch.
  2. I pretty much hate the core WordPress PHP code, no disrespect to the people that dedicated so much time to it over the years, but to me and for my purposes it’s a cluster-fuck of a headache.

Look I’m not saying I’m right in this approach, but I’m pretty sure that this approach is right for me. I follow a school of thought which basically says that if you can’t figure it out in less than an hour it’s broken (something I took away from a mesmerizing Rasmus Lerdorf keynote speech at a conference many years ago). And that’s how I felt about much of the “automagic” internals of WordPress, I couldn’t figure them out for shit and I got more and more frustrated as I started to realize that I could be writing this myself from scratch, not just in a clean manner that I would obviously intimately understand, but also in less time that it is taking me to figure out the spaghetti code. I felt the same way with the plugins, that by the time I’d searched through the thousands of plugins and actually found the one that does what I need, and installed it and played around with it, only to find that it doesn’t do exactly what I need at which point I’d have to jump back into the pool of plugins looking for another suitor. Even if I did eventually find exactly what I needed, which lets face it is rarely the case, I could have already written a more suitable and stable plugin myself.

But on the other hand the administration panel WordPress has to offer is truly something of beauty. It takes care of all the user security, roles and permissions, pages and posts with vanity URLs, WYSIWYG editors, media uploads, and comment moderating, just to mention a few of it’s highlights. Basically all the rudimentary crud we have to worry about when building a CMS from scratch, shit in my line of work the admin panel is often more complex than the front-end. And not only is it solid in it’s task, so that you can feel comfortable that it’ll do its job without having to peek under the hood, but it has some sprinkles of scriptaculous and ajax so it also does it sexy. And couple that with the fact that it’s extremely easy to implement your own custom menu items and modules to the panel makes for a great application.

So I basically ended up writing my own front-end. I got familar with WordPress and found all the functions I needed to pull in the information I was generating with the admin panel. I’d like to write about how you can get setup up with all the basics you need to get up to speed with where I am at with all of this. I’ll hopefully accomplish this by exploring the following topics over a number of entries:-

  • Create your own theme
  • Custom homepage
  • Making plugins
  • Understanding pages
  • Meta tags and custom fields
  • Custom RSS file

By the way the WordPress site I built is www.thefordstory.com

Saturday, March 7th, 2009