TRUE, 'title' => t('List of terms.'), 'icon' => 'icon_node.png', 'description' => t('Terms associated with the displayed node.'), 'required context' => new ctools_context_required(t('Node'), 'node'), 'category' => t('Node'), 'defaults' => array('title' => '', 'vocabularies' => array()), ); function ctools_term_node_content_type_render($subtype, $conf, $panel_args, $context) { $node = isset($context->data) ? drupal_clone($context->data) : NULL; $block = new stdClass(); $block->module = 'term-node'; if ($node) { $taxonomy_filtered = array(); foreach ($node->taxonomy as $tid => $term) { if (in_array($term->vid, $conf['vocabularies'])) { $taxonomy_filtered[$tid] = $term; } } $node->taxonomy = $taxonomy_filtered; $block->subject = t('Taxonomy'); $block->content = theme('links', taxonomy_link('taxonomy terms', $node)); } else { $block->subject = t('Term list'); $block->content = t('Terms go here.'); } return $block; } function ctools_admin_term_node_options($context) { if (isset($context->data->type)) { $vocabs = taxonomy_get_vocabularies($context->data->type); } else { $vocabs = taxonomy_get_vocabularies(); } $return = array(); foreach ($vocabs as $vid => $vocab) { $return[$vid] = $vocab->name; } return $return; } /** * Returns an edit form for the custom type. */ function ctools_term_node_content_type_edit_form(&$form, &$form_state) { $conf = $form_state['conf']; $form['vocabularies'] = array( '#type' => 'checkboxes', '#title' => t('Which vocabularies'), '#options' => ctools_admin_term_node_options(), '#default_value' => $conf['vocabularies'], '#prefix' => '
', '#suffix' => '
', ); } function ctools_term_node_content_type_admin_title($subtype, $conf, $context) { $options = ctools_admin_term_node_options($context); foreach ($options as $idx => $option) { if (!$conf['vocabularies'][$idx]) { unset($options[$idx]); } } return t('"@s" Terms from @type', array('@s' => $context->identifier, '@type' => implode(', ', $options))); } function ctools_term_node_content_type_edit_form_submit(&$form, &$form_state) { // Copy everything from our defaults. foreach (array_keys($form_state['plugin']['defaults']) as $key) { $form_state['conf'][$key] = $form_state['values'][$key]; } }