Useful CakePHP Tutorial Roundup for July 17, 2009

17 Jul
2009

Back on time. I think I’m going to downgrade from a firm 5 tutorials per week to just as many as I have time to review, because I don’t want to skim over material or choose sub-par stuff simply to make my quota. So, three this week. But as always, I’m constantly coming across useful tips, code, and tutorials that save me a lot of time. So I thought it might be useful to others to gather up some tutorials every Friday and just get them out there. Some are new; some are old chestnuts.

Here’s what I found useful this week:

  • Secrets of Admin Routing – Nate (July 14, 2009)
    I’ve been struggling with prefix routing – see my recent post about prefix routing and named arguments – and just when I came up with a decent (but admittedly hackish) solution to deal with the issue, along comes Nate fresh from CakeFest with a far more elegant solution. Although I still like the idea of using Router::connectNamed() to define your custom named arguments, Nate’s idea to use the AppHelper to persist custom prefixes is also a good one. Plus, you’re likely to have less custom prefixes than named arguments, so it’s more convenient just to define your prefixes in AppHelper as they come up, rather than accounting for every named argument in Router::connectNamed().
  • An Akismet Behavior – Tom O’Reilly (March 09, 2009)
    I use Akismet for this blog and it stops dozens of spam comments every day. Tom’s behavior is a great implementation of the spam-prevention service that’s easy to install. The only catch is that you need to get an API key, which you can only do by signing up for a wordpress.com account.
  • Search Engine Friendly URLs in CakePHP – Philip Klauzinski (February 03, 2009)
    The SEO experts these days claim that we should be using hyphens instead of underscores in our URLs. Easy enough on a ‘regular’ website or on a platform like WordPress (which hyphenates by defualt), but this is actually a pretty tricky process in CakePHP. While you can use something like Mariano Iglesias’ Sluggable Behavior to generate hyphenated slugs for your database items, good luck trying to replace the dashes in controller and action names! The only real solution, which, as Philip says in his tutorial, isn’t a solution at all, is to convert hyphens to underscores in your <em>app/config/bootstrap.php</em> or <em>app/config/routes.php</em>. Philip’s code for that is nice. But, this means you can’t take advantage of CakePHP’s reverse routing to generate links via the HtmlHelper and other tools. So you’re stuck writing your links manually, unless you want to hack or extend the HtmlHelper. So, the best part of this article might be the attention it draws to the issue of Cake’s support for SEO standards.

1 Response to Useful CakePHP Tutorial Roundup for July 17, 2009

Avatar

Akif

July 17th, 2009 at 7:14 am

Keep up the good work! I subscribed to your feed.

Comment Form

top