I solved some question on field type generation and learned how to render my custom field. Now, I need to use an accessible audioplayer to play my songs. In my custom field formatter view function I set item_output to render this custom field in an unordered list. Each item of this list is a link that calls a javascript function that plays automatically the song. Unfortunately, to use this player, I must set some script in header section of my page, and style css for this player. So, I need to set these scripts on ly in a page that displays this field. There is a way? Maybe in $element array returned from field formatter view function? I hope you can understand me, my english is very bad!
1 Answer
The function drupal_add_js can solve your probleme. You can try this in custom module:
function my_module_init() {
drupal_add_js(drupal_get_path('theme', 'MYTHEME') .'/my_file.js',
array('type' => 'file', 'scope' => 'header', 'weight' => 1000)
);
}
Look at this documention for use this function in diffrent way.