Adds a taxonomy edit form to a panel pane

In CUSTOM.module

/*
* Implements hook_ctools_plugin_directory -
* This lets ctools know to scan my module for a content_type plugin file
* Detailed docs in ctools/ctools.api.php
*/
function dashboards_ctools_plugin_directory($owner, $plugin_type) {
  if ($owner == 'ctools' && $plugin_type == 'content_types') {
    return 'plugins/content_types';
  }
}

function dashboards_form_taxonomy_form_term_alter(&$form, &$form_state) {
  if (strpos(current_path(), 'admin/dashboard') === 0) {
    //unset($form['description']);
    $vocabs = array(5 => t('Keywords'), 9 => t('Authors'));
    $form['vocab'] = array(
      '#type' => 'radios',
      '#title' => t('Add term to'),
      '#default_value' => 5,
      '#options' => $vocabs,
      '#description' => t('Choose the vocabulary to which the term should be added.'),
      '#weight' => -10,
    );
    array_unshift($form['#submit'], 'dashboards_form_taxonomy_form_term_submit');
  }
}

function dashboards_form_taxonomy_form_term_submit(&$form, &$form_state) {
  if (strpos(current_path(), 'admin/dashboard') === 0) {
    $form_state['values']['vid'] = $form_state['values']['vocab'];
    $vocabulary = taxonomy_vocabulary_load($form_state['values']['vocab']);
    $form_state['values']['vocabulary_machine_name'] = $vocabulary->machine_name;
  }
}

In plugins/content_types/taxonomy.inc:

/**
 * Plugins are described by creating a $plugin array which will be used
 * by the system that includes this file.
 */
$plugin = array(
  'title' => t('Taxonomy'),
  'description' => t('Custom pane for updating taxonomy terms.'),
  'category' => t('Taxonomy'),
  'single' => TRUE,
  'defaults'    => array(),
  'content type' => 'dasdhboards_taxonomy',
);

/**
* Output function for the 'taxonomy' content type.
*/
function dashboards_taxonomy_content_type_render($subtype, $conf, $panel_args, $context) {
  $pane = new stdClass();
  $pane->title = "Add taxonomy term";
  $vocabulary = taxonomy_vocabulary_load(5);
  module_load_include('inc', 'taxonomy', 'taxonomy.admin');
  $form = drupal_get_form('taxonomy_form_term', array(), $vocabulary);
  //unset($form['description']);
  $pane->content[] = $form;
  return $pane;
}

Tags: