Created
September 27, 2012 02:49
-
-
Save kraigh/3791892 to your computer and use it in GitHub Desktop.
campus id to name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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