The A-Z Directory Module – Versions 3 & 4

My rule of thumb is to increment my version of the A-Z Directory module whenever I break backwards compatibility. For me, breaking backwards compatibility in Joomla means a change in the default layout of the module that would prevent the proper display of the module if a user is using a template override. This is something I try to avoid at all costs, but sometimes there are bug fixes and features that warrant these kinds of changes.

Version 3

A user brought to my attention that multiple instances of the A-Z Directory on the same website were not displaying the contacts correctly, based on the configurable parameters in the backend. And he was absolutely right.

After talking to a dear friend of mind, far more adept at PHP than I (thank you, Leroy), he introduced me to the singleton pattern. As stated in that article:

“When designing web applications, it often makes sense conceptually and architecturally to allow access to one and only one instance of a particular class. The singleton pattern enables us to do this.”

Implementing the singleton pattern in the context of the A-Z Directory module, I was able to store the module parameters once, for each instance of the module on the website, and easily access them in the other helper functions of the module.

class modAZDirectoryHelper
{
private $params = null;
private static $_azInstance = null;
public static function azInstance( &$params )
{
if ( null == self::$_azInstance ) :
self::$_azInstance = new self( $params );
endif;
return self::$_azInstance;
}
public function __construct( &$params ) {
$this->params = $params;
}

Version 4

I’ve officially jumped on the SVG bandwagon. Prior to version 4, I was using an icon font for the contact image placeholder, and telephone, mobile, fax, email, and webpage icons. After reading several, compelling arguments for using SVG fonts instead of icon fonts, I made the switch. I used IcoMoon to generate the exact same icons I was already using, but downloaded their SVG package. Then I used Elliot Dahl’s excellent technique for aligning SVG icons to text.

Additional Resources