An easy and intelligent pagination menu for CakePHP

I recently needed to create a typical paginated directory page where people could browse via an alphabetical menu. So clicking ‘A’ returns all entries that begin with ‘A’, ‘B’ with ‘B’ and so on. CakePHP’s Paginator Helper made this all very easy.
However, there was one tricky requirement….in the menu, if there were no records [...]