I followed the MVC Tutorial from Joomla as close as possible to create my own component. I included Joomlas Tags system within my component using the Observer technique in the JTable class
class ComponentTableItem extends JTable
{
function __construct(&$db)
{
parent::__construct('#__cmp_item', 'id', $db);
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_component.item'));
}
}
Inserting new items and adding Tags works fine. But when I delete the item, the tags associations are not deleted. I use the following code to delete multiple entries in Model/Items.php:
public function delete(&$pks)
{
$db = JFactory::getDbo();
$pks = (array)$pks;
// Iterate the items to delete each one.
foreach ($pks as $i => $pk) {
$item = JTable::getInstance('item', 'ComponentTable');
$item->load($pk);
//...do some stuff
//and finally delete the item
$item->delete($pk);
}
}
I was under the impression that the ObserverClass in the JTable class would take care of it, but that doesn't seem to be the case. Any pointers?