I would like to be able to automatically output the videos attached to my 'video' content type node using a template. At the moment I have a template called node-video.tpl.php which has this line in it.
print flashvideo_get_video($node);
That works fine if I have only one video attached to the node, but if I have 2 or more it only outputs the first one. Is there a way I can get all videos to be automatically displayed on the node using a custom template? I don't want to require my users to have to type in:-
[video]
[video:index=1]
etc.
Also what do I use to output the thumbnail for a teaser in my template. I can do a test to see if it's a teaser but I don't know what function to call to display the thumbnail (i.e. instead of [thumbnail]).
Thanks in advance for any help you can give me.
Comments
Comment #1
NeilPorter commentedOr is there a way to restrict only one video per node? Anyone?
Comment #2
NeilPorter commentedI've been banging my head on this one for ages now. Travist, surely you know a way to use the function in the template to display all the videos attached to the node and not just the first one?
Comment #3
NeilPorter commentedIs it that this is impossible with the current code setup or that it's so simple no one is bothering to even tell me because I'm such a dunce?
Comment #4
attheshow commentedI will say that I don't know how to do this yet, although I haven't looked through the flashvideo_get_video function to see what's possible.
Comment #5
NeilPorter commentedThanks for replying attheshow, I was beginning to get paranoid! I'm still looking into this myself but I don't think I'm quite the coder you are so...!
Comment #6
attheshow commentedI did a little bit more investigation. It looks like you should be able to do this with the following snippet in your template file:
...but it's not working on my setup. It creates an invalid query (it's pointing at an incorrect table). I'm going to commit a small change to the query (will appear in the 1.x-dev version). We'll see if that fixes it.
Comment #7
NeilPorter commentedThank you very much for your efforts. Would you be kind enough to outline the change here so I might patch my version until the dev version makes it to a release.
Comment #8
attheshow commentedSure. In version 1.4 of the module, line 1785 of flashvideo.module should be changed to
$sql = "SELECT f.fid FROM {flashvideo} fv LEFT JOIN {files} f ON f.fid = fv.fid WHERE $flashmime AND (fv.status=%d) AND (fv.nid=%d)";Again, I'm not positive that this will work for the display method you're seeking, but it's worth a shot. And this query definitely needed to be corrected regardless.
Comment #9
NeilPorter commentedThank you very much. I've made the change and now no longer get the error with this in the template:-
$params['fids'] = 'node'; print flashvideo_get_video($node, $params);However it doesn't work as I had hoped.
To test it I attached 4 videos to a node and using the above in my template it only displays the second video and nothing more. Have you got any more ideas on this?
Comment #10
attheshow commentedNeil,
I believe that when you list all of the files attached to a node, in the way we're discussing above, the module attempts to use some sort of "playlist" functionality to generate the listing. I seem to remember seeing other issues in the queue saying that playlist functionality isn't working for some people in the Drupal 6 version. I'm fairly new to this part of the module code (I haven't used playlists yet myself), so I'll have to dig into it a little bit this evening and see what the issue is. Maybe if I get lucky, I can kill two birds with one stone.
This afternoon, I'm going to be continuing my work on a separate feature #227410: FlashVideo and CCK FileField Integration. I'll get back to this hopefully this evening and see what I can tell you.
-Mark (attheshow)
Comment #11
attheshow commentedOk, I made some bug fixes in the playlist include file. Playlists in general were broken prior to this. I recommend giving the 1.x-dev version a shot on your development server and seeing if this change allows you to view all of the videos attached to the node. I believe they are meant to play one after the other in the same player.
Comment #12
attheshow commentedThe playlist is definitely fixed in the 1.x-dev version of the module. I needed to add an extra Flash variable into my Custom Flashvars:
&playlist=bottomIn order to get the listing of node files to display below the first video. Apparently this is the correct behavior according to the JW Player site.
http://www.longtailvideo.com/support/jw-player-setup-wizard?example=6