Mercurial > hg > drupalISMI
diff 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 |
line wrap: on
line diff
--- a/openmindattribute/openmindattribute.module Wed Jun 17 18:57:22 2015 +0200 +++ b/openmindattribute/openmindattribute.module Fri Jun 19 18:13:21 2015 +0200 @@ -236,7 +236,7 @@ 'variables' => array('type' => NULL, 'attributes' => NULL), ), 'openmindattribute_formatter_fields_specialized' => array( - 'variables' => array('type' => NULL, 'attributes' => NULL), + 'variables' => array('type' => NULL, 'attributes' => NULL, 'relations' => NULL), ), 'openmindattribute_formatter_field_identifier' => array( 'variables' => array('type' => NULL, 'attributes' => NULL), @@ -616,15 +616,33 @@ $term = taxonomy_term_load($ocid); - + // put unpacked openmind attributes in #attributes (key: attribute name) $atts = $entity->field_attribute['und']; $atts_mapped = _openmindattribute_field_remap($atts); + // put unpacked openmind relations in #relations (key: relation type) + // the relation's direction is ignored. the 'other' object is the value. + $rels = relation_query('node', $entity->nid)->execute(); + $relations = array(); + foreach ($rels as $rel) { + $relNode = relation_load($rel->rid); + $eps = relation_get_endpoints($relNode); + foreach($eps as $ep) { + foreach ($ep as $node) { + // is this endpoint this object? + if ($node != $entity) { + // its another object -> save + $relations[$rel->relation_type][] = $node; + } + } + } + } $elements = array( '#theme' => 'openmindattribute_formatter_fields_specialized', '#attributes' => $atts_mapped, + '#relations' => $relations, '#type' => $term->name ); @@ -933,15 +951,9 @@ function theme_openmindattribute_formatter_fields_specialized($vars) { $type = $vars['type']; - return theme_render_template(drupal_get_path('module', 'openmindattribute') . "/templates/openmindattribute_" . $type . ".tpl.php", $vars); - - - - - }