1

How can I query the db for all the tags associated with an article?

I have been able to use JTable to query to *_tags table, but that doesn't return the tags that are associated with the article record.

I'm interesting in something like:

$tags = JTags::searchByArticleId(1);
2

Use TagsHelper::getItemTags():

use Joomla\CMS\Helper\TagsHelper; $tags = new TagsHelper; $tags->getItemTags('com_content.article', $articleId); Where $articleId is article ID. Tags will be available through $tags->itemTags.

If you already have article object loaded, you can add tags to it:

$article->tags = new TagsHelper; $article->tags->getItemTags('com_content.article', $article->id);

  • I eventually stumbled on this, but nice to have it confirmed. Thank you. – steel Jul 20 '18 at 15:01

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.