Drupal: Floating Bar

This CodeLet creates a floating bar at the bottom edge of the browser. The CodeLet specifically created for music player over the floating bar in the same manner as MySpace.

CodeLet: 

/**
* @file
*
* Display a floating music player
* @author DrupalD
*/

/**
* Implementation of hook_init
*
* @return unknown_type
* @author DrupalD
*/
function music_player_init() {
drupal_add_css(drupal_get_path("module", 'music_player') ."/music_player.css");
drupal_add_js(drupal_get_path("module", 'music_player') ."/music_player.js");
}

/**
* Implementation of hook_theme
*
* @param unknown_type $existing
* @param unknown_type $type
* @param unknown_type $theme
* @param unknown_type $path
* @return unknown_type
* @author DrupalD
*/
function music_player_theme($existing, $type, $theme, $path) {
return array(
'music_player' => array(
'arguments' => array(),
),
);
}

/**
* theme_music_player
*
* @return unknown_type
* @author DrupalD
*/
function theme_music_player() {
$form = array(
'' => "select",
'' => t("Playlist"),
'' => TRUE,
'' => 3,
'' => get_playlist(),
'' => array('class' => 'playlist'),
);

$ss__playlist = drupal_render(form_builder($form_id, $form, $form_status));
return
'

>
||

'. $ss__playlist .'

';
}

/**
* Implementation of hook_footer
* @param $main
* @return unknown_type
* @author DrupalD
*/
function music_player_footer($main = 0) {
global $user;
if (in_array('Fan', $user->roles) || in_array('admin', $user->roles) || $user->uid == 1) {
return theme('music_player');
}
}

/**
* get_playlist
*
* @author DrupalD
*/
function get_playlist() {
$r__result = db_query("SELECT title, nid FROM {node} WHERE type = 'myPlaylist' AND status = 1");

while($om__result = db_fetch_object($r__result)) {
$am__playlist[$om__result->nid] = $om__result->title;
}

return $am__playlist;
}

Drupal: Floating Bar | Drupal Developer

By DrupalD on Thu, 30/05/2013 - 9:38am

Add comment

Log in or register to post comments
QR code for this page URL This page URL
Feedback