Macrotone Blogs

Macrotone blogs upon Joomla, our products and other matters.
Font size: +

Implementing Joomla 3.1 Tags feature

J3.1-Transparent-bgWe originally implemented the Joomla 3.1 tags feature within our Issue Tracker component. This was done using the documentation[1] by Elin Waring the originator of the feature.  This worked fine until Joomla 3.1.4 was released when it changed to use the JObserver classes.

The basic change (as we understand it) is that the tag fields were originally stored within the ‘metadata’ field where as using the (new) JObserver class removes this requirement and the tag is not required to be saved with the item at all. Both methods were intended to be supported but the implementation is broken, but may well be fixed in a later update.

We found another document[2] describing the modified configuration/setup. The problem was we couldn’t get it to work as it was described.

We eventually found a solution which is as follows.

1) In the components table class we added the following line:

JTableObserverTags::createObserver($this, array('typeAlias' => 'com_xxxxxxxxxx.yyyyyy'));

Where the component is xxxxxxxxxx and yyyyyy is the tag type.  (The differs from the suggestion in the documentation[2] which we couldn’t get working.)

2) Double check the field mappings which get placed in the #__content_types table.  The configuration document[2] shows square braces in the string but these are not required or necessary.  It is also important that the field mappings accurately match the fields within the referenced table.  A small mistype or wrong name will result in an error being generated when the tab is saved.  It doesn’t help that the error message only tells one that an error has occurred not what the actual error is.  We found out through trial and error. [We note that there are a few other fields in the #__ucm_content table that can also be populated, notably the created_by_alias.]

3) We also found that we required the following in the getItem method of the model (despite the documentation[2] saying otherwise).

$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_xxxxxxxxxx.yyyyyy');
// $item->metadata['tags'] = $item->tags;

The last line we have commented out since we do not observe any impact of it being present.

4) In one of our tag types we were using the table class method called directly, calling the various bind, check and table store methods. This meant that some code that is required to handle the tags did not get called.  The easiest way we resolved this was to instead call the parent:save  routine. This was achieved by slightly restructuring the model save method and also meant that we didn’t have to add additional code and also enabled us to simplified our code.

5) The other change we made was to the 'Hathor' template view overrides to display the tags. Again the suggestion in the documentation[2] didn't work for use and we resorted to the standard display mechanism.

Strange 1604 errors with upgraded Joomla 3.1.5
Updating Transifex Source files
 
Go To Top

Joomla! Debug Console

Session

Profile Information

Memory Usage

Database Queries