Archive for the 'Code' Category

Zend_Acl and Zend_Auth Example

Thursday, February 8th, 2007

Simon Mundy has written up a well-worth-reading Zend_Acl / Zend_Auth example scenario in which he illustrates setting up authorisation and access privileges with the Zend Framework.

Vim tips articles

Thursday, October 26th, 2006

A quick pointer to a really useful series of Vim articles by Joe ‘Zonker’ Brockmeier that also appear on Linux.com.

Planula

Sunday, October 22nd, 2006

Planula Bed and Breakfast Retreat

We’ve been working with Tim and Wandy, the owners of Planula Bed and Breakfast/Divers Retreat, for over three years now on their site underwater.com.au and for almost the same amount of time have been saying that we need to update the Planula site.

Well of course we’re happy to say it’s now done and was released a few days ago.

Having successfully maintained their own website for years, Tim and Wandy were, and still are, understandably hesitant about moving from a static HTML site they knew, to a new database-driven solution. I’d like to run through a few of the reasons we encouraged (bullied?) them into using WordPress.

I’ve mentioned some general reasons to use a solution like WordPress in a previous post. Here are a few more specific ones which, while referring to Planula, are equally relevant to many sites.

Speed and relative simplicity of publishing.

They were already doing a lot of copying and pasting to add new content which works fine for consistent content but is a more work if, for example, new pages need to be added.

Consistency.

It’s very easy on a static html site for small inconsistencies to build up over time and become harder to change, e.g. with navigational elements. Altering the left navigation in the new site is now as simple as adding new pages and/or shuffling current ones in admin.

Syndicated content

Their latest content can now be consumed by anyone who subscribes to it via the automatically generated newsfeeds. This is an effortless form of marketing and can be used in a variety of ways such as their “Latest News” on the Planula listing page on underwater.com.au.

More freedom to change their minds

There are always sections in websites that aren’t immediately clear and need time and use to get a better idea on how they should be approached. This is much easier if things can be moved around quickly to respond to changing needs or circumstances.

But what if…

It would be naive to pretend that this solution is the be-all, end-all and I’ve already mentioned Tim and Wandy having some hesitation. Their primary concern was how much they would be tied to this solution and what if they needed to change to another or back to a static HTML site?

Thankfully this is also a common concern for developers and therefore there are several solutions or “exit strategies”:

Changing to another system

Methods exist to import WordPress data into other solutions, such as Textpattern and Drupal. As a sidenote; It’s quite notable just how many more there seem to be for [importing into WordPress](http://codex.wordpress.org/Importing_Content “Importing content into WordPress).

Converting back to static HTML

It would be possible to do this via WordPress itself but there already exist other solutions like Blue Crab which “is a program that you use to copy the contents of a website to your computer, in whole or in part”. This is a Mac desktop application but of course Windows equivalents exist

Some other things

Another point worth mentioning; the site has now moved from a tables-based layout to one based on CSS stylesheets which on the whole (apart from the markup introduced by a few plugins) means somewhat smaller pages sizes and more content dense HTML. The separation of the page styling also means future changes to the look of the site can be introduced across the whole site much more quickly.

Final words

We’re waiting to see how these changes affect the visits and search engine behaviour of what is already a popular website. Of course we’re hoping they improve even more.

So go visit the site and even better visit Byron Bay and stay at Planula!

Decorating Zend Developer Zone

Thursday, September 28th, 2006

If you’re in the mood for design patterns, my article, Decorating with External Data has just been published on Zend Developer Zone and runs through an example of using the Decorator.

I’m really interested to see it get a bit of a kicking from those who really know their design patterns, so if you’re one of those people please let me know of anything I should or should not do in the comments here or at DevZone.

Diving into WordPress

Wednesday, September 27th, 2006

Yes, I know the title is a little cheesy, but it does introduce some of the recent projects we have been working on.

One of the things that is often requested is a means for businesses to update their own content and this generally requires some kind of content management system. For previous larger projects like underwater.com.au, the requirements have been specific enough to require a custom system to be developed. For smaller projects, however, a custom solution is often overkill. In this article I’m going to run through some of the thoughts that went into developing a couple of sites using WordPress.

Yongala Dive

Yongala Dive website screenshotYongala Dive is a small dive resort based in the Great Barrier Reef Marine Park which primarily runs trips to the famous S.S. Yongala Wreck.

Their previous static site was difficult to update and maintain and was also in need of search engine optimisation. We started by looking at their statistics to get an indication of how the site was being used and from that came up with the following overview:

  1. First users looked for information about the S.S. Yongala wreck.
  2. Then they wanted to know about the people providing the service.
  3. Then about the service they provide.
  4. Then they looked at images in the gallery.
  5. At this point they seemed ready to contact them.

These were some of the findings that were used in the development of the site and influenced decisions, such as, what order pages appeared in the site navigation.

I initially started looking at using a pared down version of our own content management system but decided that in this case it would have been the wrong choice. Instead, the advantages of using a solution like WordPress include:

  • You can spend more time solving business problems than on the inevitable tweaking of your in-house engine.
  • It is free, used all over the place, many hosts actually have it as a package.
  • It is well documented.
  • Finding someone in the future to develop for it will be many times easier than finding someone to develop for an in-house custom solution.
  • You will be able to take advantage of the many available plugins like gallery, calendar, weather, etc. Plus, of course, you can also build plugins.

Bear in mind that many of the above benefits apply not only to your involvement in the project, but also in the case of you no longer working on the site. If, for example, your client employs an in-house developer it will be to your benefit to have allowed for that.

WordPress Plugins Used

Australian Divemaster Academy

Australian Divemaster Academy website screenshotThe Australian Divemaster Academy is an initiative of Byron Bay Dive Centre, taking students from beginner to Divemaster in 10 weeks of training.

The main requirement for this site, aside from introducing the course, was to provide a means for the non-technical staff to update news and the program calendar. The relative simplicity of WordPress’ “Write Post” process was really the key reason to use it.

We also added the WP-iCal plugin to publish the calendar posts to an .ics format so that calendar applications like iCal, Sunbird and the upcoming Outlook 2007, can subscribe and be kept up to date with program availability.

WordPress Plugins Used

Conclusion

WordPress is not a panacea and I have to admit that moving from developing object-oriented, MVC-architected, design-pattern-influenced, ok-I-sound-like-a-wanker, code to WordPress and many of its plugins feels like a step back in time. Articles recommending what not to do when developing modern PHP applications could find examples in WordPress and its plugins.

Just to mention a few: Functions are often huge and on occasion perform everything from querying the database to outputting the HTML. The API seems geared mainly towards retrieving HTML output when often you’d like to set or retrieve more basic data like an array or an integer. Many plugins would benefit greatly from updating the indexing of the database columns but make no such recommendation.

One example is a plugin that had database queries nested in two levels of loops. Having first retrieved some data, it used it to loop through another query and in turn, used that to loop through a further query. In a small test it had already run over 100 queries and would have increased in line with the number of posts. A reworking of the code reduced the total queries down to 2. (Note: I did do what you’re supposed to do with open-source code you see needing some work; fix it and send its developer the reworked solution. I’ve intentionally not named the plugin as a mark of gratitude to anyone who gives their time to helping others out.)

However, before I go on and on, getting all precious and code nazi, I have to admit that it is fun to hack away at WordPress. If your client makes a request the first thing you can do is Google for a plugin. Often there are a selection that almost meet the mark which can then be used as a prototype to show the client. If not immediately appropriate, most can be adapted to the needs of the business.

In short while you still need to be vigilant there is a real sense of liberation in being able to focus on finding solutions to your clients needs rather than getting overly (and the danger being unnecessarily) precious about the code itself.

Rob Allen’s Zend Framework Tutorial

Friday, August 18th, 2006

Anyone looking for a good comprehensive run through of a Zend Framework application should read Rob Allen’s My Take on a Zend Framework Tutorial.

As it’s a PDF, you might like to read it using this trick from Jon Udell: Vertical PowerBook as ebook reader. He uses a Mac but I’m sure you can achieve much the same on other OS’s.