I was wondering if someone could give me a hand with the code to make a "Last Audio Node" Block that can be used on the sidebar. It would be best if it could be played while the user is browsing the current page.

Comments

jdelaune’s picture

Create a view to produce a block with the filefield field and the MP3 Player display. Filter it to the latest created node and limit it to 1.

Cactii1’s picture

I don't want to use Views...

Substitute your database fields where necessary... Maybe someone has a better way of doing this with table joins, if you do please let me know.

<?php
$nid = db_result(db_query("SELECT  `nid` FROM  `{node}` WHERE  `type` =  'audio_broadcasts' ORDER BY 'created' DESC LIMIT 1"));

$fid = db_result(db_query("SELECT  `field_audio_broadcast_fid` FROM  `{content_type_audio_broadcasts}` WHERE  `nid` =  '$nid' LIMIT 1"));

$url = db_result(db_query("SELECT  `filepath` FROM  `{files}` WHERE  `fid` =  '$fid' LIMIT 1"));

print theme('mp3player', 'Default', 'http://www.example.com/'.$url, NULL, NULL, '');
?>
jdelaune’s picture

Status: Active » Closed (fixed)