Kelly Divine
Kelly Divine

Reputation: 41

How to save programmatically new tag in joomla

In joomla we have api to save article:

require_once (JPATH_BASE.'/administrator/components/com_content/models/article.php'); 
$new_article = new ContentModelArticle();
$data = array(
    'title' => "new article",
    'introtext' => "This is new article",
    'fulltext' => "The End!",
);
$new_article->save($data);

now i want add tags in my article. #new #article #End
How can i do it?

Upvotes: 2

Views: 544

Answers (1)

Jose Luis Algara
Jose Luis Algara

Reputation: 175

Insert the tags in array format.

$new_article->newTags = ['ID_tag_one', 'ID_tag_two', 'etc']; //array of tag IDs

Upvotes: 2

Related Questions