Adding Funding Project info to EML

Research Project content modification

To add the eml for <project> element I added additional fields to the Research Project content:  Project Funding and Funding Number 

Update Jan 2019:  One final step was missing from this doc.  The newly created field needs to be unhidden in the dataset eml display.  See the details at the end of this blog.

(The motivation for this was for data replicated to the Arctic Data Center  which needs the funding grant numbers.)

Funding number/s can be a list of numbers separated by a comma.

This is how it looks when adding or editing Research Project.

Adding EML Template for Research Project

In profiles/deims/modules/custom/eml/templates created file  eml--node--project.tpl.php

with the following code:

<project>
<title><?php print $label; ?></title>
<?php /** Render the investigator information.  needed to add role as PI **/
$investigators=render($content['field_related_people']);
print str_replace('</personnel>','<role>principalInvestigator</role></personnel>',$investigators);
?>
<abstract>
<?php print render($content['field_abstract']); ?>
<?php print render($content['field_project_funding']); ?>
</abstract>
<funding>
<?php
$fundingNo = str_replace(array("<literalLayout>","</literalLayout>"),array("",""),render($content['field_funding_number']));
print str_replace(',','</para><para>',$fundingNo);
?>
</funding>
</project>

_

Note that EML text Format outputs <para> <literalLayout>the funding number</literalLayout> </para> Whereas we want <para>the funding number</para>
The str_replace gets rid of the <literalLayer> tags.  The second str_replace was in case the numbers are entered as a comma delimit string.  Probably can delete that line.

___________________________________________________________

Enable EML display mode in Research Project

In EML display mode of the Reserach Project change as follows:
 

The investigators field will be reneder with eml element getting the name, address, etc  For the funing number I needed to remove the literalout elements that EML text puts on and replace the list of grant numbers with <para> element.


In the eml--node--data-set.tpl.php

 Add the project output after the medthods rendering.:

.........
    <?php if (!empty($content['methods'])): ?>
    <methods>
      <?php print render($content['methods']); ?>
    </methods>
    <?php endif; ?>
    
    <?php if (!empty($content['field_project'])):
             print render($content['field_project']);
          endif; ?>
    

    <?php print render($content['field_data_sources']); ?>
  </dataset>

.......


In the data set  Manage display  EML tab  Project needs to be unhidden.  Change to EML element.