organic drupal-7 organic-groups

drupal 7 - organic - Crear un grupo orgánico programáticamente



drupal 7 group (2)

Estoy buscando una forma de crear un grupo orgánico en código. En la web, encuentro recursos manny sobre cómo agregar un nodo a un grupo, etc., pero no cómo crear un grupo en sí mismo.

Lo hice usando la interfaz drupal, pero esto no es muy portátil. Intenté usar el módulo de funciones, aunque descubrí que tenía muchos problemas. Campos faltantes, etc.

A través de la interfaz, usted crea un grupo creando un nuevo tipo de contenido, y luego, debajo de la pestaña ''grupos orgánicos'', selecciona ''grupo''

Sé cómo crear un tipo de contenido en código

$type = array( ''type'' => ''Termbase2type'', ''name'' => t(''Termbase2name''), ''base'' => ''node_content'', ''custom'' => 1, ''modified'' => 1, ''locked'' => 0, ''title_label'' => ''Termbase2'', ''description'' => ''s a database consisting of concept-oriented terminological entries (or ‘concepts’) and related information, usually in multilingual format. Entries may include any of the following additional information: a definition; source or context of the term; subject area, domain, or industry; grammatical information (verb, noun, etc.); notes; usage label (figurative, American English, formal, etc.); author (‘created by’), creation/modification date (‘created/modified at’); verification status (‘verified’ or ‘approved’ terms), and an ID. A termbase allows for the systematic management of approved or verified terms and is a powerful tool for promoting consistency in terminology. *wiki'', ''og_group_type'' => 1, ''og_private'' => 0, ''og_register'' => 0, ''og_directory'' => 0, ''og_selective'' => 3, ); $type = node_type_set_defaults($type); node_type_save($type); node_add_body_field($type);

pero no puedo encontrar ninguna pista sobre cómo configurar el tipo de contenido como un grupo, por lo que puede tener miembros de grupo.



Esto funcionó:

// get existing content types $content_types = node_type_get_types(); $t = get_t(); // create the currency CT $type_name = ''cc''; if (!array_key_exists($type_name, $content_types)) { // Create the type definition array. $type = array( ''type'' => $type_name, ''name'' => $t(''Community Currency''), ''base'' => ''node_content'', ''description'' => $t(''A community that trades in a virtual currency.''), ''custom'' => 1, ''modified'' => 1, ''locked'' => 0, ); $type = node_type_set_defaults($type); node_type_save($type); // Add a body field. node_add_body_field($type); variable_set(''og_group_type_'' . $type_name, TRUE); og_ui_node_type_save($type_name); }