Store new tags to the contentitem_tag_map

21 views
Skip to first unread message

pherfinion

unread,
May 27, 2017, 12:28:40 PM5/27/17
to Joomla! General Development
Hello,

i've try to insert update an article with y own  component. Now i've the problem that i try to inser the given tags in the contentitem_tag_map. Now idea how it works.

GTX pherfinion

pherfinion

unread,
May 28, 2017, 7:52:34 AM5/28/17
to Joomla! General Development
Found the solution:

$basePath = JPATH_ADMINISTRATOR.'/components/com_content';
require_once $basePath.'/models/article.php';
$articlemodel = new ContentModelArticle(array('table_path' => $basePath . '/tables'));

$params = array(
    'id' => 123,                // Article being tagged
    'tags' => array(7,8,9,14)   // Tag IDs from #__tags to tag article with
);
if($articlemodel->save($params)){
    echo 'Success!';
}

https://stackoverflow.com/questions/17886406/joomla-3-1-4-how-to-insert-tags-programmatically
Reply all
Reply to author
Forward
0 new messages