Bradezone

Archive for ‘Web Stuff’

Thursday, March 10th, 2011

Apples to Crapples

If there are any fans of Charlie Sheen left, they probably work for Apple. The 300-billion-dollar tech behemoth would be only too pleased to see someone else on the receiving end of public furor these days. But I for one shall not allow some meth-addled celebrity to quell my indignation over their recently announced 30% App Store subscription fee.

Since that momentous announcement, reaction has poured in from just about every website and media outlet imaginable, so much so that there might be nothing further to add. However, ceasing discussion of this issue would be a complacent resignation in the face of an increasingly overbearing corporate power. The fact is that Apple is treading into the same waters that so many powerful firms before them have entered, and there is no reason to think their hubris won’t elicit the same public backlash that thwarted their predecessors’ ambitions. Apple has become a classic example of the Big Brother they mocked in 1984–a company who specializes in closed systems and believes they know what is best for you every step of the way.

You can read more about the specifics and implications of Apple’s new policy in the back and forth between Seth Godin and John Gruber (who does a spot-on O’Brien imitation). You can read Ryan Carson’s heartfelt denouncement, which details precisely how small businesses would be extorted. You can also read how Apple’s closed App Store platform eventually deterred 37 Signals from developing for it, so they could instead launch their mobile app on the still wide-open platform of the web. These are all inevitable reactions to Apple’s overt attempts to control a major media outlet.

Closed systems in and of themselves are not good or evil. The billion-dollar video game industry has thrived with proprietary consoles from Nintendo, Sony and Microsoft. But there is a drastic difference between the consumption of games and the consumption of content and information. If this discussion only concerned the likes of Angry Birds and Cut the Rope, there would be mild irritation. But when the subject of consideration is the essential exchange of information, which heretofore has flourished under the freely accessible infrastructure of the world wide web, the tone of the argument changes dramatically. There will be a torrent of anger indeed, and it won’t just come from the birds.

NOTE: This post originally appeared on the Merge blog.

Thursday, January 6th, 2011

Query Strings and the CakePHP Paginator

Since my earlier CakePHP post seemed to help some folks out, I’m back with another Pro-Tip that improves Cake’s handling of paged results. Its built-in pagination functions are nearly ideal except for one glaring problem: the query string is not preserved between pages. This adds unnecessary difficulty when implementing such basic functionality as search results, which often rely on the query string (See: Google).

You may have already picked up the common advice to add the following code to your views:

$paginator->options(array('url' => $this->passedArgs));

Normally the passedArgs here are simply the parameters for the current action, which are part of the current page’s URL. In most cases you want to preserve these, so the code above will do that for you. However, the query string is not preserved, so we need to add a bit of extra code. Luckily the “url” option maps to an array that is processed by the core Router url function. If one of these array keys is “?” then its value (either a string or an array) will be transformed into a query string for the resulting URL. We simply want to include the current query string as it already exists, so we can use a built-in PHP function to do that, then merge it with passedArgs in our final code:

$paginator->options(array('url' => array_merge($this->passedArgs,
array('?' => ltrim(strstr($_SERVER['QUERY_STRING'], '&'), '&')))));

The reason we have to incorporate ltrim and strstr is because CakePHP already processes every page request with a “behind the scenes” query string that contains an initial “url” variable. We don’t need this for our purposes, so we discard it and take the rest of the query string.

Truthfully I feel like this functionality should be nicely integrated into Cake by default, instead of requiring the use of this fix. Perhaps another $paginator option is needed in the view that allows one of three values for URL preservation: the current action only (which is presently the default), the full URL minus the query string, and the full URL including the query string (which I believe should be the default). But until then, I hope this tweak can help you out.

Thursday, June 10th, 2010

Simple or Flexible… or Both?

A one-for-all, all-for-one solution to website content management is the holy grail of my profession. For my web development work for clients, I find that several of them have a lot of specific features they want in their content management system (CMS). But soon enough I’m walking the tight rope between simplicity and flexibility.

Selecting a tool to build such a website or application is a matter of audience. The first audience, software developers, need either a lot of freedom or a lot of options. In practical terms, for my PHP development, this is a choice between CakePHP and Drupal. Working with both of these equally has been eye-opening, because without fail there are many features that are much faster to implement in one or the other—it truly ends up about 50/50. Want to display a custom calculation in a specific place on the site? With CakePHP it’s simple. Want a paged image gallery with Lightbox functionality? Drupal can get you there much more quickly.

For both these platforms, the other audience comes into play as well, namely the client. Obviously the client needs to have their available options presented as concisely as possible—they don’t need (or want) a huge amount of freedom or options. So the creation of such a simple interface falls to the developer. The trick is knowing which stuff to allow them to change and which stuff to hard-code. In both cases, priority #1 is defining these as variables (or object properties) as soon as possible in the code, so we can switch back and forth if need be. Yet clients will always possess an uncanny knack for requesting the tweaks that are most troublesome to implement. Granular permissions, anyone?

Creating robust software that is still easy to use is the challenge facing any software developer. Apple has rightly gained a reputation for striking this balance with substantial success, yet they are certainly not above reproach. In the web industry, the balance of power is more volatile, as anyone with a great idea can launch a web application with little to no concern for infrastructure—innovations from Google, Rackspace, Amazon, and the like are taking care of those issues. And while there are a wealth of options in the realm of content management, several of them quite good, I believe this abundance indicates the ongoing problem of balancing features with simplicity in these applications. After a myriad attempts, the world still awaits a truly excellent CMS.

NOTE: Parts of this post were originally a comment at Gadgetopia.