1

I'm looking to create tags programmatically. I've done it through a direct DB insert but that doesn't seem to be working correctly as I can't associated those created tags with a piece of content via the observer.

I'm looking for something like this:

$content = JTable::getInstance("Content", 'JTable', array());
$content->load($id);
JHelperTags::addTags(array("tag1", "tag2"), $content);

JHelperTags has a method that may do what I want, but I don't understand the arguments. The following does not work

$h = new JHelperTags();
$h->tagItem($content->id, $content, array("tag1", "tag2"));

How can I programmatically create tags that will be correctly stored in Joomla?

1

I was able to use createTagsFromField. #new# has to be appended to the title if the tag doesn't exist.

$title = "Tag Title";
$h = new JHelperTags;
$h->createTagsFromField(array("#new#$title"));

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.