Some basic fields for Views would be very handy.
Eg. a field for showing the Flash file.

CommentFileSizeAuthor
#7 views_flashnode.inc_.txt981 bytesjoachim

Comments

chrisroditis’s picture

I second that request! Thanks for the great module!

Stuart Greenfield’s picture

I've never really used Views much before now.

Can you describe a bit more what you'd want Views + flash node to do? What views would you like to make possible that can't be done with the current set up?!

joachim’s picture

Probably just a field that shows the Flash file would be enough. I don't see that there's anything useful you'd want to do with filters or sorts or arguments.

Stuart Greenfield’s picture

I had a look at the Views module, and there's a bit of a learning curve for me to work out how to do this.

When you say Probably just a field that shows the Flash file would be enough do you mean a link to the flash file, or actually have the flash file itself showing/playing?

I like the idea of views support as I know a lot of people use it to help customise their site, but I'm not quite sure how best to combine it with flash node.

I'll leave it open and start to have a little play around to see if I can get something working, but in the meantime if anyone else is interested in flash node + views then post here to describe what sort of functionality you'd like so it gives me some sort of framework to develop/test in!

Also, due to time constraints on my part I'm going to start working this up for D6 / flash node 6 first although the post is against flash node 5. The Views framework changes a lot in D6 it seems, so I'd like to start with support for the latest version, and then port it back!

joachim’s picture

I meant the flash file showing/playing. So for example, you could do a list of 'Recent flash posts' in a block, or all flash posts by a particular user.

I have some experience writing Views plugins for D5, and I'll probably be needing to code this feature for a client's site in the next couple of weeks. So I could help with the D5 version. (Views API for D5 and D6 is fairly different, so it's not so much a case of backporting as writing it all over again)
What I haven't yet figured out is how to display the flash file given the node ID -- which function(s) in your module provide that?

Stuart Greenfield’s picture

There are a few ways you could do it. The easiest one is probably to call flashnode_content(). This is documented by comments in the code, but basically you pass an array of arguments, of which the only required one is a node nid. It returns the markup to render the flash element. It will return the markup in "native" flash node format, or in SWF Tools format, depending how your setup is configured.

If you did it that way you would have access to the same set of parameters as the flash node filter takes. If you supply no other arguments you'd get the flash at full size, but you could equally constrain heights and/or widths with this function which might be helpful in a summary view. The filter syntax (and therefore options for the function) is described on this documentation page.

All the flash node output is now ultimately generated by the theme('flashnode') function, so you could call that directly. However, using flashnode_content() will load the necessary data with just the nid, so that might be a shortcut you can use!

Thinking out loud, would it be possible to expose a view that can call flashnode_content(), and maybe let the user set a fixed size? Then you could produce a summary list of flash content, all scaled to some standard size. That would be neat for, say, a site that is hosting lots of flash games. Downside would be that you potentially load a LOT of flash on one page? Alternatively, the same approach would mean a site with lots of media could have a summary list with the appropriate media player (e.g. 1PixelOut) rendered somewhere.

Any help with views much appreciated as it's all new to me :-)

joachim’s picture

Status: Active » Needs review
StatusFileSize
new981 bytes

Here's it isfor D5/Views1:

First add this code to the top of flashnode.module:

if (module_exists('views')) {
  include(drupal_get_path('module', 'flashnode') .'/views_flashnode.inc');
}

Then rename the attached file to 'views_flashnode.inc' (had to add the .txt to allow it to attach) and put it in the module folder.

This gives you a field in Views that shows the flash file with the player.

Regarding settings the size: there's only one form field for specifying additional options. According to the Views documentations, more than one form API element can be shoehorned in (http://drupal.org/node/99792), but it looks pretty hairy. I don't have time to work on it now, though if it turns out later on my client needs that, I'll look into it :)

Sorry I can't help with D6/Views2. The API has changed, but as far as I know it's documented and the general principle is the same, just changes to views hooks and the finer details of what you return in your arrays.

Stuart Greenfield’s picture

Excellent - thanks very much for this. I have had a quick look and already made a few changes, but this looks like it could be very, very neat. So much so I have just created branch DRUPAL-5--6 to put the code in as I can see a new release is going to be on its way.

If you look at CVS you'll see I made a few changes. First bit is minor - I called the inc file flashnode.views.inc which will be consistent with the Drupal 6 version.

Now the interesting stuff. I was getting an error when I first launched the Views with flash node. That looks like it was because the options field was using an undefined string called $players. But then the options field got me thinking, why not make that a simple text field, and then the user can supply an arbitrary string of options in flash node filter syntax.

With a minor change to the handler code we can process that string, and send it straight to flashnode_content(), so not only can the user call up all the content, they can change the size. In particular, they can send the parameter scaleheight or scalewidth to limit the presentation to suit their page. I tried it locally and it works great - a neat little summary table of all my flash content!

Having now used views (for the first time!) I can see why this was a request.

Thanks again for the patch, and comments welcome on the revised code!

Stuart Greenfield’s picture

OK, I can't quite get my head around this (it's been a long week). It would be neat if we could have a filter to say "Only show me swf", or "Only show me flv", as then we could filter the swf, audio or video content.

But I can't see how to grab the filename...

joachim’s picture

> Now the interesting stuff. I was getting an error when I first launched the Views with flash node. That looks like it was because the options field was using an undefined string called $players.

Oops! I was cribbing from audio.module. That 'options' key shouldn't be there at all, at least not in the state I left it in.

> But then the options field got me thinking, why not make that a simple text field, and then the user can supply an arbitrary string of options in flash node filter syntax.

Yes, that's a really good idea. (Why didn't I think of that...?)

> But then the options field got me thinking, why not make that a simple text field, and then the user can supply an arbitrary string of options in flash node filter syntax.

OTOH I can't remember where you're storing the filename. In the files table, I presume?
You'll need to define another entry in the tables array, aliasing the files table, I think ... there was something in the Views docs about joining with several tables.

The only thing I'd say about the latest version of the code is that reusing the $data variable makes it harder to read.
Other than that looks great!
Looking forward to a new release!

Stuart Greenfield’s picture

Making headway!

I have a query that is now extracting the filename. At the moment it is just extracting the filename, but it should just (!) be a small step to check the file extension and filter on the different content types...

Also by using an inner join instead of a left join then adding the flash content to a view automatically limits the listing to flash node types so you don't have to apply a filter as well.

Uploading to CVS, and then I really must go to bed!

joachim’s picture

I hesitated over using an inner join or a left join. I can see a case for wanting to return nodes of different types, and showing flash for flashnodes and maybe some other field for the other nodes. Eg a list of both image nodes and flashnodes.

Stuart Greenfield’s picture

Posted some minor changes up to DRUPAL-5--6 branch. I can't decide on the inner versus left join, so have put it as a left join and the users can filter for type = flashnode for now!

I took a quick look at Views for D6, and need to sit down and concentrate - looks like it might be a more extensive change, particularly around the way handlers are written!

Anyone out there with Views 2 experience that can help migrate what turned out to be quite simple code for D5.

Thanks again @joachim for getting Views for flash node 5 underway!

Stuart Greenfield’s picture

Good news - I have a working version of flash node 6 with Views 2. Bad news is I'm not currently able to access CVS so I will have to post it later - but it is working!

henrijs.seso’s picture

Congrats! Great module now even greater with Views support. And now - final challenge before complete victory - CCK support! Cheers!

Stuart Greenfield’s picture

Thanks for the enthusiastic comments about flash node :-)

Victory is getting closer... I am trying to work on "flash node CCK" at the moment. Along with keeping my day job going!

Stuart Greenfield’s picture

Views2 support for flash node 6 is now available from HEAD. It implements the same features as the flash node views for D5 - i.e. you can add a field that renders flash node content, and optionally scales it, and you can also capture the filepath associated with the file. This means you can create a view that filters by, say, .mp3 or .flv as the extension, so you can create views that only show audio, video or flash content.

Seems to be behaving for me, so if anyone can test it to cross check that would be great. If it's looking stable then this will become a new release.

Stuart Greenfield’s picture

Status: Needs review » Fixed

Committed and included in latest releases.

Status: Fixed » Closed (fixed)

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