I recently found Joomla’s feature to easily add custom component-specific nested Categories. It makes for a quick way to create categories similar to what is used in com_content and an interface to manage those categories without having to build it all manually. You can use JForm to easily add a select menu of your custom categories. The categories interface can even include a custom sub-menu to easily get back to the rest of your component.

It’s nearly as easy as just using a custom administrator URL, such as:

index.php?option=com_mycomp&view=categories&extension=com_mycomp

…where com_mycomp is changed to the “option” name of your component. The “extension” parameter at the end is what separates your Categories from the rest, and can either be for the whole Component, or a specific view or data type within the Component, with a dot to separate from the component name.

It took some digging to figure out how to customize the sub-navigation to be specific to my component. Apparently Joomla (2.5) looks for a helper class here:

(your component) /helpers/mycomp.php

…where mycomp.php matches the name of your component/option, minus the “com_” part. The helper class name follows the convention:

MycompHelper

…again replacing “Mycomp” with your component name. From there, Joomla looks for a method named addSubmenu, and will use that to build the sub-navigation when in the Category manager. For instance:

class MpimHeloper
{
	public static function addSubmenu($selected=null)
	{
		$option = 'com_mpcomp';
		JSubMenuHelper::addEntry(
			'Component Home',
			'index.php?option='.$option,
			$selected=='home'
		);
		JSubMenuHelper::addEntry(
			'Another Component Section',
			'index.php?option='.$option.'&view=myview',
			$selected=='myview'
		);
	}
}

Finally, to use a list of the component’s categories in a JForm XML file (as a select menu), use:

<field name="mycategory" 
type="category" 
extension="com_mycomp"
label="Select a category" />