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

NeilPorter’s picture

Or is there a way to restrict only one video per node? Anyone?

NeilPorter’s picture

Title: How to set up my node template » Setting up node template to automatically display more than one video

I'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?

NeilPorter’s picture

Is 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?

attheshow’s picture

I 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.

NeilPorter’s picture

Thanks 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...!

attheshow’s picture

I did a little bit more investigation. It looks like you should be able to do this with the following snippet in your template file:

<?php
$params['fids'] = 'node';
print flashvideo_get_video($node, $params);
?>

...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.

NeilPorter’s picture

Thank 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.

attheshow’s picture

Sure. 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.

NeilPorter’s picture

Thank 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?

attheshow’s picture

Neil,

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)

attheshow’s picture

Ok, 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.

attheshow’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Assigned: Unassigned » attheshow
Status: Active » Fixed

The 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=bottom

In 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

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.