Mercurial > hg > drupalISMI
comparison openmindattribute/openmindattribute.module @ 7:f651752ee9ad
add relations to openmindattribute template variables. use relations for person template.
author | casties |
---|---|
date | Fri, 19 Jun 2015 18:13:21 +0200 |
parents | 124ef8f3b22d |
children | cf772424f725 |
comparison
equal
deleted
inserted
replaced
6:447623f107dc | 7:f651752ee9ad |
---|---|
234 ), | 234 ), |
235 'openmindattribute_formatter_fields_default' => array( | 235 'openmindattribute_formatter_fields_default' => array( |
236 'variables' => array('type' => NULL, 'attributes' => NULL), | 236 'variables' => array('type' => NULL, 'attributes' => NULL), |
237 ), | 237 ), |
238 'openmindattribute_formatter_fields_specialized' => array( | 238 'openmindattribute_formatter_fields_specialized' => array( |
239 'variables' => array('type' => NULL, 'attributes' => NULL), | 239 'variables' => array('type' => NULL, 'attributes' => NULL, 'relations' => NULL), |
240 ), | 240 ), |
241 'openmindattribute_formatter_field_identifier' => array( | 241 'openmindattribute_formatter_field_identifier' => array( |
242 'variables' => array('type' => NULL, 'attributes' => NULL), | 242 'variables' => array('type' => NULL, 'attributes' => NULL), |
243 ), | 243 ), |
244 | 244 |
614 | 614 |
615 $ocid = $entity->field_oc['und'][0]['tid']; | 615 $ocid = $entity->field_oc['und'][0]['tid']; |
616 | 616 |
617 $term = taxonomy_term_load($ocid); | 617 $term = taxonomy_term_load($ocid); |
618 | 618 |
619 | 619 // put unpacked openmind attributes in #attributes (key: attribute name) |
620 $atts = $entity->field_attribute['und']; | 620 $atts = $entity->field_attribute['und']; |
621 | 621 |
622 $atts_mapped = _openmindattribute_field_remap($atts); | 622 $atts_mapped = _openmindattribute_field_remap($atts); |
623 | 623 |
624 // put unpacked openmind relations in #relations (key: relation type) | |
625 // the relation's direction is ignored. the 'other' object is the value. | |
626 $rels = relation_query('node', $entity->nid)->execute(); | |
627 $relations = array(); | |
628 foreach ($rels as $rel) { | |
629 $relNode = relation_load($rel->rid); | |
630 $eps = relation_get_endpoints($relNode); | |
631 foreach($eps as $ep) { | |
632 foreach ($ep as $node) { | |
633 // is this endpoint this object? | |
634 if ($node != $entity) { | |
635 // its another object -> save | |
636 $relations[$rel->relation_type][] = $node; | |
637 } | |
638 } | |
639 } | |
640 } | |
624 | 641 |
625 $elements = array( | 642 $elements = array( |
626 '#theme' => 'openmindattribute_formatter_fields_specialized', | 643 '#theme' => 'openmindattribute_formatter_fields_specialized', |
627 '#attributes' => $atts_mapped, | 644 '#attributes' => $atts_mapped, |
645 '#relations' => $relations, | |
628 '#type' => $term->name | 646 '#type' => $term->name |
629 ); | 647 ); |
630 | 648 |
631 break; | 649 break; |
632 | 650 |
931 } | 949 } |
932 | 950 |
933 function theme_openmindattribute_formatter_fields_specialized($vars) { | 951 function theme_openmindattribute_formatter_fields_specialized($vars) { |
934 | 952 |
935 $type = $vars['type']; | 953 $type = $vars['type']; |
936 | |
937 | 954 |
938 return theme_render_template(drupal_get_path('module', 'openmindattribute') . "/templates/openmindattribute_" . $type . ".tpl.php", $vars); | 955 return theme_render_template(drupal_get_path('module', 'openmindattribute') . "/templates/openmindattribute_" . $type . ".tpl.php", $vars); |
939 | |
940 | |
941 | |
942 | |
943 | |
944 | 956 |
945 } | 957 } |
946 | 958 |
947 | 959 |
948 | 960 |