Created
December 14, 2016 20:03
-
-
Save banoodle/8dfa0bbe174fe0f37202da65b9f3ebe9 to your computer and use it in GitHub Desktop.
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
<?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