I've recently installed OG Vocabulary and have been kicking the tires for the last day or so. It'll do what I need it to do, that is, provide segregated group taxonomies. However, it seems to me that the workflow is less than ideal.

I have a content type named Event. It has 2 OG fields:

og_group_ref - Allows the user to associate content to a group

og_vocabulary - Contains select lists of vocabularies based on which groups the user belongs to, and whether those groups have referenced vocabularies.

When creating a new Event, if a user belongs to multiple groups with taxonomies on that node, the user is shown a og_vocabulary field for every group. This allows a user to associate the Event to "Group A", but select terms from "Group B".

After a new Event is created and associated to a group, if a user goes back to edit that group, only vocabularies related to the group they've associated to the node show up. If the user changes the group to which the content belongs, they must save that content then edit the content again in order for the correct og_vocabulary field to show up. I'd like to be able to skip having to go back in and edit the node after changing the referenced group.

Is it possible to dynamically load the correct og_vocabulary field based on the value of og_group_ref?

I've been mucking around with AJAX to accomplish this, but I'm wondering if there's a better way to accomplish this. It's possible that this functionality is built in and I'm missing something.

I'm using D7, by the way.

Thanks for any help!

closed as too broad by tenken, Елин Й., Yusef Mohamadi, Letharion, AyeshK Oct 16 '14 at 10:59

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


I recently encountered the same issue and the way I got around it was to use a hook_form_alter to use the appropriate taxonomy from the pre-populated selection of og_group_ref via a db_select on the taxonomy_term_data table.

I used entity_reference_prepopulate to set up the link to create group content for the group. Seems hacky to me and would like to know if others were able to get it to work like the OP had wanted it. Here is an excerpt of my hook_form_alter.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  // ... get gid from context
  // ... i used request_uri() to get the uri and parsed out the gid
  // there may be less hacky ways of doing this.
  $query = 'SELECT tdata.tid, tdata.name FROM (SELECT vid from {og_vocab_relation} where gid=:groupid) og left join {taxonomy_term_data} tdata on (og.vid=tdata.vid)';
  $query_params = array(':groupid' => $gid);
  $taxi_terms = db_query($query, $query_params);
  $options = array();
  $options['_none'] = '- None -';
  foreach($taxi_terms as $taxi_term) {
    $options[$taxi_term->tid] = $taxi_term->name;
  $form['og_vocabulary'] =  array(
    '#title' => 'Projects',
    '#type' => 'select',
    '#multiple' => TRUE,
    '#options' => $options
  • This is essentially what I ended up doing. I added a little bit of Ajax to the form, too. – Squishus Tyrannicus Sep 29 '14 at 12:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.