4 * Plugins are described by creating a $plugin array which will be used
5 * by the system that includes this file.
9 'title' => t('Term name'),
10 'icon' => 'icon_term.png',
11 'description' => t('The name of this taxonomy term.'),
12 'required context' => new ctools_context_required(t('Term'), array('term', 'taxonomy_term')),
13 'category' => t('Taxonomy term'),
24 * Render the custom content type.
26 function ctools_term_name_content_type_render($subtype, $conf, $panel_args, $context) {
27 if (empty($context) || empty($context->data)) {
31 // Get a shortcut to the term.
32 $term = $context->data;
34 // Load the vocabulary.
35 $vocab = taxonomy_vocabulary_load($term->vid);
38 $content = !empty($conf['link']) ? l($term->name, 'taxonomy/term/' . $term->tid) : check_plain($term->name);
40 // Build any surrounding markup if so configured
41 if (isset($conf['markup']) && $conf['markup'] != 'none') {
42 $markup = '<' . $conf['markup'];
43 if (!empty($conf['id'])) {
44 $markup .= ' id="' . $conf['id'] . '"';
46 if (!empty($conf['class'])) {
47 $markup .= ' class="' . $conf['class'] . '"';
49 $markup .= '>' . $content . '</' . $conf['markup'] . '>' . "\n";
53 // Build the content type block.
54 $block = new stdClass();
55 $block->module = 'term_name';
56 $block->title = t('Name');
57 $block->content = $content;
58 $block->delta = $term->tid;
64 * Returns an edit form for custom type settings.
66 function ctools_term_name_content_type_edit_form($form, &$form_state) {
67 $conf = $form_state['conf'];
69 $form['markup'] = array(
70 '#title' => t('Title tag'),
73 'none' => t('- No tag -'),
82 '#default_value' => $conf['markup'],
86 '#title' => t('CSS id to use'),
87 '#type' => 'textfield',
88 '#default_value' => $conf['id'],
91 $form['class'] = array(
92 '#title' => t('CSS class to use'),
93 '#type' => 'textfield',
94 '#default_value' => $conf['class'],
97 $form['link'] = array(
98 '#title' => t('Link to term'),
99 '#type' => 'checkbox',
100 '#default_value' => $conf['link'],
101 '#description' => t('Check here to make the name link to the term page.'),
107 * Submit handler for the custom type settings form.
109 function ctools_term_name_content_type_edit_form_submit($form, &$form_state) {
110 // Copy everything from our defaults.
111 foreach (array_keys($form_state['plugin']['defaults']) as $key) {
112 $form_state['conf'][$key] = $form_state['values'][$key];
117 * Returns the administrative title for a type.
119 function ctools_term_name_content_type_admin_title($subtype, $conf, $context) {
120 return t('"@s" name', array('@s' => $context->identifier));