Snippet: WordPress 3.0 Menus - Add a login / logout link

The new WordPress 3.0 menu system is pretty powerful and provides some very interesting new options for creating menus in WordPress. Previously, I have always used wp_list_pages and a custom Walker class to provide hierarchical menus based on the page structure, but that's a topic for another…

Snippet: Magento - Using OR and LEFT JOIN in addAttributeToFilter

I'm still pretty new to Magento, and am learning more about it every day. I've been trying to learn all I can about internals such as managing collections & recently stumbled on trying to filter a collection by two attributes. I wanted to build a list of all products that…

Snippet: Symfony & Propel - Queries with SQL functions

This is a super short snippet that I ALWAYS forget how to do! Often I want to build more complex where clauses with Propel Criteria which use SQL functions such as UCASE, LCASE, LEN and the date functions DAY, MONTH and YEAR. This is possible using Propel & Criteria, but…

Snippet: Symfony Forms - Accessing the Object in a Form

Perusing my Google Analytics data shows up some interesting results. For starters the top search query which sends people to my blog is "symfony accessing object in a form". This has been consistent for several months, but there is no article on my blog which answers that question. I imagine…

Snippet: Wordpress Admin - Tidy Dashboard Widgets By Role

Recently I worked on a Wordpress site where I wanted to be able to customise the dashboard for different user roles. Wordpress has the default roles of administrators, editors, authors, contributors and subscribers. It's not too much to assume you might not want to show your editors or authors all…

Snippet: Creating & Debugging Complex SQL queries in Symfony

When working with large and complex datasets in Symfony, there comes a point where the ORM layer (Propel or Doctrine) causes more problems than it solves. Sometimes it's necessary to debug large SQL queries built using the ORM layer, and at other times it'sĀ appropriate to bypass the ORM layer…

Snippet: Wordpress - Customise the Excerpt Length and More string

These functions and hooks let you customise the output of the_excerpt() template tag. Just copy and paste into the functions.php file in your theme. This works for both posts and pages. To change the excerpt length (how many words are output - the default is 55 words) , define…

Snippet: Symfony Forms - Definition List Form Formatter

Back in April I posted a Snippet on Symfony Form Formatters. Since then I've done a bit more work with them and thought I'd share my custom form formatter for displaying forms as definition lists. Forms are often marked up as unordered lists, but with their label-input structure I find…