Mercurial > hg > drupalISMI
changeset 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 | 447623f107dc |
children | 5148098e96a4 |
files | openmindattribute/openmindattribute.module openmindattribute/templates/openmindattribute_PERSON.tpl.php relation_processor/relation_processor.info |
diffstat | 3 files changed, 52 insertions(+), 24 deletions(-) [+] |
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); - - - - - }
--- a/openmindattribute/templates/openmindattribute_PERSON.tpl.php Wed Jun 17 18:57:22 2015 +0200 +++ b/openmindattribute/templates/openmindattribute_PERSON.tpl.php Fri Jun 19 18:13:21 2015 +0200 @@ -1,29 +1,45 @@ <h3 class="openmindattribute-header">Details</h3> + <table class="openmindattribute-table" > <tr class="openmindattribute-row"> <td class="openmindattribute-cell openmindattribute-name">Name</td> -<td class="openmindattribute-cell"><?php print $attributes['name_translit']['ov']?><br/><?php print $attributes['name']['ov']?></td> -</tr> - -<tr class="openmindattribute-row"> -<td class="openmindattribute-cell openmindattribute-name">Name (romanization)</td> -<td class="openmindattribute-cell"><?php print $attributes['name_translit']['romanization']?></td> -</tr> - -<tr class="openmindattribute-row"> -<td class="openmindattribute-cell openmindattribute-name">Notes</td> -<td class="openmindattribute-cell"><?php print $attributes['notes']['ov']?></td> +<td class="openmindattribute-cell"><?php print $attributes['name']['ov'] ?><br/> +<?php print $attributes['name_translit']['romanization']?></td> </tr> +<?php if ($attributes['notes']['ov'] != ''): ?> <tr class="openmindattribute-row"> -<td class="openmindattribute-cell openmindattribute-name">Date of birth</td> -<td class="openmindattribute-cell"><?php print $attributes['birth_date_text']['ov']?></td> +<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'] != ''): ?> +<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> +</tr> +<?php endif; ?> +<?php if (isset($relations['was_born_in'])): ?> <tr class="openmindattribute-row"> -<td class="openmindattribute-cell openmindattribute-name">Date of death</td> -<td class="openmindattribute-cell"><?php print $attributes['death_date_text']['ov']?></td> +<td class="openmindattribute-cell openmindattribute-name">Place of Birth</td> +<td class="openmindattribute-cell"><?php print $relations['was_born_in'][0]->title ?></td> </tr> +<?php endif; ?> +<?php if ($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> +</tr> +<?php endif; ?> + +<?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> +</tr> +<?php endif; ?> </table> \ No newline at end of file
--- a/relation_processor/relation_processor.info Wed Jun 17 18:57:22 2015 +0200 +++ b/relation_processor/relation_processor.info Fri Jun 19 18:13:21 2015 +0200 @@ -1,5 +1,5 @@ name = relation_processor -description = Processes relaitons +description = Processes relations package = Feeds core = 7.x dependencies[] = ctools