Mercurial > hg > drupalISMI
changeset 9:cf772424f725
changed representation of relations in template. relations have source and target now.
author | casties |
---|---|
date | Mon, 22 Jun 2015 19:02:34 +0200 |
parents | 5148098e96a4 |
children | 2a786f0d46a7 |
files | openmindattribute/openmindattribute.module openmindattribute/templates/openmindattribute_PERSON.tpl.php |
diffstat | 2 files changed, 26 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/openmindattribute/openmindattribute.module Fri Jun 19 18:58:25 2015 +0200 +++ b/openmindattribute/openmindattribute.module Mon Jun 22 19:02:34 2015 +0200 @@ -572,14 +572,9 @@ $term = taxonomy_term_load($ocid); - $atts = $entity->field_attribute['und']; $atts_mapped = _openmindattribute_field_remap($atts); - - - - $elements[$delta] = array( '#theme' => 'openmindattribute_reference_format', @@ -588,30 +583,21 @@ '#attributes' => $atts_mapped, '#ov' =>$entity->field_ov['und'][0]['value'], '#nid' => $entity->nid - - ); } return $elements; } - - - - - } if ($field['type'] == 'openmindattribute_fields'){ // nur ausgabe feld! - + switch($display['type']){ - case ("openmindattribute_fields_specialized"): - $ocid = $entity->field_oc['und'][0]['tid']; $term = taxonomy_term_load($ocid); @@ -622,20 +608,19 @@ $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. + // the relations are in a list. each element is an array with the keys 'source' and 'target'. $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; - } - } + $epv = array_values($ep); + $st = [ + 'source' => $epv[0], + 'target' => $epv[1] + ]; + $relations[$rel->relation_type][] = $st; } }
--- a/openmindattribute/templates/openmindattribute_PERSON.tpl.php Fri Jun 19 18:58:25 2015 +0200 +++ b/openmindattribute/templates/openmindattribute_PERSON.tpl.php Mon Jun 22 19:02:34 2015 +0200 @@ -7,14 +7,7 @@ <?php print $attributes['name_translit']['romanization']?></td> </tr> -<?php if ($attributes['notes']['ov'] != ''): ?> -<tr class="openmindattribute-row"> -<td class="openmindattribute-cell openmindattribute-name">Notes</td> -<td class="openmindattribute-cell"><?php print $attributes['notes']['ov'] ?></td> -</tr> -<?php endif; ?> - -<?php if ($attributes['birth_date_text']['ov'] != ''): ?> +<?php if (isset($attributes['birth_date_text']['ov'])): ?> <tr class="openmindattribute-row"> <td class="openmindattribute-cell openmindattribute-name">Birth Date</td> <td class="openmindattribute-cell"><?php print $attributes['birth_date_text']['ov'] ?></td> @@ -24,11 +17,11 @@ <?php if (isset($relations['was_born_in'])): ?> <tr class="openmindattribute-row"> <td class="openmindattribute-cell openmindattribute-name">Place of Birth</td> -<td class="openmindattribute-cell"><?php print $relations['was_born_in'][0]->title ?></td> +<td class="openmindattribute-cell"><?php print $relations['was_born_in'][0]['target']->title ?></td> </tr> <?php endif; ?> -<?php if ($attributes['death_date_text']['ov'] != ''): ?> +<?php if (isset($attributes['death_date_text']['ov'])): ?> <tr class="openmindattribute-row"> <td class="openmindattribute-cell openmindattribute-name">Death Date</td> <td class="openmindattribute-cell"><?php print $attributes['death_date_text']['ov'] ?></td> @@ -38,7 +31,21 @@ <?php if (isset($relations['died_in'])): ?> <tr class="openmindattribute-row"> <td class="openmindattribute-cell openmindattribute-name">Place of Death</td> -<td class="openmindattribute-cell"><?php print $relations['died_in'][0]->title ?></td> +<td class="openmindattribute-cell"><?php print $relations['died_in'][0]['target']->title ?></td> +</tr> +<?php endif; ?> + +<?php if (isset($relations['was_student_of'])): ?> +<tr class="openmindattribute-row"> +<td class="openmindattribute-cell openmindattribute-name">Teachers</td> +<td class="openmindattribute-cell"><?php print $relations['was_student_of'][0]['target']->title ?></td> +</tr> +<?php endif; ?> + +<?php if (isset($attributes['notes']['ov'])): ?> +<tr class="openmindattribute-row"> +<td class="openmindattribute-cell openmindattribute-name">Notes</td> +<td class="openmindattribute-cell"><?php print $attributes['notes']['ov'] ?></td> </tr> <?php endif; ?>