Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php // If there is audio content, print it with it's description.
if (isset($content['field_audio_file'])) {
// Hide so we can display it later.
hide($content['field_audio_file']);
print '<div class="field-item">';
// Loop through each audio file.
$audiofiles = $content['field_audio_file']['#items'];
foreach ($audiofiles as $delta => $audiofile) {
$uri = $audiofile['uri'];
$audiopath = file_create_url($uri); // Converts uri to path format.
print '<div class="audio-field">';
// If there is a description, display it.
if (isset($audiofile['description'])) {
print '<div class="label">' . $audiofile['description'] . '</div>';
}
// Display audio player.
print '<audio controls="controls"><source src="' . $audiopath . '" type="audio/mpeg" >
</audio></div>';
}
print '</div>';
} ?>
<div class="content">
<?php print render($content); // Render the rest of the node's fields. ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment