term_from_node.inc
Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 function panels_term_from_node_panels_relationships() {
00012 $args['term_from_node'] = array(
00013 'title' => t("Term from node"),
00014 'keyword' => 'term',
00015 'description' => t('Adds a taxonomy term from a node context; if multiple terms are selected, this will get the "first" term only.'),
00016 'required context' => new panels_required_context(t('Node'), 'node'),
00017 'context' => 'panels_term_from_node_context',
00018 'settings form' => 'panels_term_from_node_settings_form',
00019 'settings form validate' => 'panels_term_from_node_settings_form_validate',
00020 );
00021 return $args;
00022 }
00023
00024
00025
00026
00027 function panels_term_from_node_context($context = NULL, $conf) {
00028
00029 if (empty($context->data)) {
00030 return panels_context_create_empty('term', NULL);
00031 }
00032
00033 if (isset($context->data->taxonomy)) {
00034 foreach ($context->data->taxonomy as $term) {
00035 if ($term->vid == $conf['vid']) {
00036 return panels_context_create('term', $term);
00037 }
00038 }
00039 }
00040 }
00041
00042
00043
00044
00045 function panels_term_from_node_settings_form($conf) {
00046 $options = array();
00047 foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
00048 $options[$vid] = $vocabulary->name;
00049 }
00050 $form['vid'] = array(
00051 '#title' => t('Vocabulary'),
00052 '#type' => 'select',
00053 '#options' => $options,
00054 '#default_value' => $conf['vid'],
00055 '#prefix' => '<div class="clear-block">',
00056 '#suffix' => '</div>',
00057 );
00058
00059 return $form;
00060 }
00061