首页 > 解决方案 > How to programically add all the nodes of content type article to one group in drupal 8?

问题描述

I am looking for a solution to add all the nodes of content type article to a group with group id=25, Is there any way to add them once through PHP code, I heard about the function addcontent in groups , but I don't know how to use it, please help me out

Group::addContent(ContentEntityInterface $entity, $plugin_id, $values = [])

How to use the above function?

Is there any way to do one step process?

Group::addContent(ContentEntityInterface $entity, $plugin_id, $values = [])

I need to all the content type of articles to group with gid=25

标签: phpdrupal-8

解决方案


May be it will help

$group->addContent($entity, 'group_node:article');

plugin_id is actually node type

please try it.


推荐阅读