0

I have two vocabularies named 'vocab_one' and 'vocab_two'. I create custom multiple blocks module named 'add library', in order to display the taxonomy 'add terms' form to each blocks.

Each block displayed on the same node in the content area. The position of 'Vocab Two Block' are above 'Vocab One Block'.

When I add new term on 'Vocab One Block', the new term is always stored in the 'vocab_two'. Then I switch position of the block. This time, the new term is always stored in the 'vocab_one'.

How to store a new term within selected vocabulary, without worrying about the block position?

here is my add_library.module:

function add_library_block_info() {
  $blocks['Vocab Two Block'] = array(
    'info' => t('Vocab Two'),
  );

  $blocks['Vocab Two Block'] = array(
    'info' => t('Vocab One'),
  );

  return $blocks;
}

function add_library_block_view($delta='') {
  $block = array();
  switch ($delta) {
    case 'Vocab Two Block':
      $block['subject'] = t('Add Vocab Two');
      $block['content'] = add_vocab_two();
      break;
    case 'Vocab Two Block':
      $block['subject'] = t('Add Vocab One');
      $block['content'] = add_vocab_one();
      break;
  }
  return $block;
}

function add_vocab_two() {
    module_load_include('inc', 'taxonomy', 'taxonomy.admin');
    $vocabulary = taxonomy_vocabulary_load(2);
    return drupal_get_form('taxonomy_form_term', $vocabulary);
}

function add_vocab_one() {
    module_load_include('inc', 'taxonomy', 'taxonomy.admin');
    $vocabulary = taxonomy_vocabulary_load(4);
    return drupal_get_form('taxonomy_form_term', $vocabulary);
}
0

Every block must have unique delta, so in hook_block_info first $blocks change 'Vocab Two Block' to 'vocab_block_first', second $blocks 'Vocab Two Block' change to 'vocab_block_second', then in 'switch' change first 'case Vocab Two Block' to 'case vocab_block_first' and second 'case Vocab Two Block' to 'case vocab_block_second'. Then show these two blocks on the same place.

  • I already adjust the code, same result.<br/> $blocks['vocab_block_first'] = array(<br/> $blocks['vocab_block_second'] = array(<br/> case 'vocab_block_first':<br/> case 'vocab_block_second':<br/> <br/> new term is always stored in the first block vocabulary. – DE51GN Nov 18 '12 at 9:07
  • Try to reinstall add_library module, then show first and second block, or clean all cache – svetlio Nov 18 '12 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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