Skip to content

Instantly share code, notes, and snippets.

@kraigh
Created September 27, 2012 02:49
Show Gist options
  • Save kraigh/3791892 to your computer and use it in GitHub Desktop.
Save kraigh/3791892 to your computer and use it in GitHub Desktop.
campus id to name
//Charlie's function:
/**
* Return the campus name for a given ID.
*/
function jnet5_campus_name_by_pbid($campus_id) {
$campuses = _jnet_purl_campuses();
foreach ($campuses as $campus) {
if ($campus['pb_id'] == $campus_id) {
$campus_name = $campus['label'];
}
}
if (isset($campus_name)) {
return $campus_name;
} else {
return FALSE;
}
}
//How he called it in the TPL:
$campus_id = field_get_items('node', $node, 'field_campus_id');
$campus_name = ($campus_id) ? jnet5_campus_name_by_pbid($campus_id[0]['value']) : FALSE;
//How i'm trying to call it from the custom php field:
<?php
$campus_id = $row->field_campus_id;
$campus_name = jnet5_campus_name_by_pbid($campus_id);
print $campus_name;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment