select a non-default player for a views display of a filefield
ju.ri - June 26, 2009 - 16:19
| Project: | SWF Tools |
| Version: | 6.x-2.5 |
| Component: | Documentation |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I've been trying for hours to display a cck filefield in a view with a player other than the selected swf default. After trying all sorts of embedding, rewriting, customfield (php), and things like that, nothing worked out. Does anyone have an idea?
Otherwise this could become a feature suggestion for directly selecting different players in cck and views display options. I display everything on my site through CKK or Views, so at the moment it is impossible for me to have more than one player per filetype.
thanks for any ideas

#1
I now found a way to do this by using the "views-customfield" module to be able to insert the php code for a certain player into a view.
So first I added a relationship to the view, adding the filefield of the node as the relation. That way I can pull in the path of the filefield-file, not only the fid. Then I add the path of the file as a field to the view, and choose not to display it.
THe "customfield" has the great feature that it can use any other field (sorted before the custom field) as a variable. So I can put this in the php-code-area:
<?phpprint swf($data->files_node_data_field_MY_FILEFIELD_filepath,
array(
'methods' => array('player' => 'generic_mp3'),
)
);
?>
Maybe someone finds this information useful. Thanks for listening anyway :)
#2
Automatically closed -- issue fixed for 2 weeks with no activity.
#3
May be the following sample PHP code for views-customfield will help someone to save a lot of time:
<?php$result = db_query("SELECT filename, filepath FROM `files`WHERE fid ='%s'",$data->node_data_field_video_field_video_fid);
$file=db_fetch_object($result);
if ($file->filepath) {
$url = file_create_url($file->filepath);
print swf($url,
array(
'methods' => array('player' => 'wijering4_mediaplayer'),
)
);
}
?>
File path is retrieved and displayed in wijering4 mediaplayer. The player string I found defined in the module of the player:
<?phpdefine('WIJERING4_MEDIAPLAYER', 'wijering4_mediaplayer'); // 'player', can display mixed files
define('WIJERING4_IMAGEROTATOR', 'wijering4_imagerotator'); // 'player', can display images.
define('WIJERING4_DOWNLOAD', 'http://www.jeroenwijering.com/?item=JW_FLV_Media_Player');
?>
I guess you can find similar ID string for the other players defined in their modules.
Would be nicer though when SWFtools by itself would enable the player in the view and therefore I change this thread into a feature request