The structure of the #__content_types table is fairly straightforward:

Column name

Column type

Purpose

type_id

int(10)

Record key

type_title

varchar(255)

Type title e.g. Article

type_alias

varchar(255)

Type alias e.g. com_content.article

table

varchar(255)

Information about the Table class

rules

text

Not currently used

field_mappings

text

Maps the table column names to standard Joomla! names

router

varchar(255)

Optional: name of a router method

Construct the Content Type entry

For each table/option/view you will need to make an entry in #__content_types table (see above).

type_id

This is the auto-incremented record key, nothing to be done here.

type_title

The title for your Content Type e.g. Article, Contact, Weblink, You can do this either using sql or postflight by creating an instance of JTableContenttype. Don't forget a category type if you use the Joomla categories API.

type_alias

A string identifying the component and view (that would be in the page request, typically matching the model name) e.g. com_contact.contact, com_weblinks.weblink.

table

You need to identify which tables used by your component contain records to be tagged. For example the 'Contact' view of the Contacts component uses #__contact_details and similarly the 'Weblinks' view of the Weblinks component uses #__weblinks .

Each of these components uses a class to write to the table: ContactTableContact for the Contacts component and WeblinksTableWeblink for the Weblinks component. You will need the class prefixes e.g. ContactTable, WeblinksTable.

Note that Category types all use the #__categories table.

The type_table entry gives the complete table class information for the table class as a JSON object with two elements. The first element represents your "special" table and the second an optional common table (otherwise it will default the JTableCorecontent).

An option array, as used in your component constructor and getInstance() methods, may be empty

This information enables the tagging system (and other APIs) to access your table easily.

If you are using Joomla categories make sure to create a category type so that they can be tagged. In Joomla 3.1 and 3.1.1 there is an error where the tag field will show even if there is not a type, but this is corrected in 3.1.4.

Notes

The table name for the common table is #__ucm_content; this is INCORRECT in 3.1 and 3.1.1 data but is not currently used. The data was updated in 3.1.4.

The type_title field would potentially be used for display although this is not implemented currently except in the contenttype field. Usually it should begin with an upper case letter if it is in English. See note about how to make this translatable. To make your type names translatable add COM_TAGS_CONTENT_TYPE_+type_title="Type Title" in both the ini and sys.ini files.

rules

Rules is currently not used. It will likely be removed in favor of an asset_id for each type, but currently you can ignore this field which will be managed by JTable.

field_mappings

This entry maps the names of specific fields in your table to a set of standard names. This mapping is stored as a JSON array with the first element mapping to the common fields and the second one mapping the other fields from the table.

Important note The JHelperTags and JUcm APIS at 3.1.1 supported arrays for this field, but as of 3.1.4 either arrays or objects with a default of objects are supported.

is the field mapping for the Article type. Note that article uses the name attribs for the core field called params. If your table does not contain a field, put “null” instead. Leaving it blank may cause SQL issues. The special fields are optional. At a minimum for common fields you need to map: content_item_id, alias and title in order to successfully create urls in the tagged items list. You also will probably want: access, status, and language.

router

Router is an optional entry to include the name of a static helper router method for this type found in its front end helpers folder.

If you only store data in #__ucm_content you will eventually be able to leave the router field blank although this option is not currently implemented. If you do not have a custom router tags falls back to the rules found in JHelperRoute.

Add tags to the getItem() method of the model

Note: this was only required in 3.1.0 and 3.1.1. It should not be used in 3.1.4 or later. Please read the history of this page if you need instructions for older versions.

Add a tag field to edit screens

In any edit layouts where you want to allow tagging, you need to add the field to the xml and the appropriate layouts if necessary. The core layouts us a JLayout to manage this and the same layout by any extension.

Update: Note that in 3.1.1 only there is special handling of this in the core. Tags in the edit screen MUST be part of a metadata <fields></fields> group. The core provides two JLayouts to help you manage standard layouts, one (details) for the metadata and one for the sidebar that includes the tabs. In update an extension to 3.1.4 you may need to fix adjust your edit views.

In 3.1.4 or later this special handling is not necessary. Best practice is to use the standard JLayouts since this provides a consistent experience for users.

The field also includes an attribute to allow/deny the user to enter custom values. Currently this only works in AJAX mode. The attribute has to be added to the field definition like **custom="allow"** or **custom="deny"**

if it is not already there. Usually multiple should be true unless you have a specific reason for it not to be. In the core components in administrator, the field is in the group shown on the right, below the language field.

Note: As of 3.1.2 if you wish to use the field to designate parent tags you must add parent="parent" to the xml definition of the field.

Prepare the view

Add an appropriate version of this to your view.html.php file before loading the layout:

The first parameter should match a type in the types table. The second parameter is the primary key under which this record is stored in your table. This would be used in any display in any view where you want the tags associated with the item to display.

Set up the display

In any layout where you want to display the tags associated with an item add: