Active
Project:
MediaFront
Version:
6.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Jul 2010 at 23:45 UTC
Updated:
6 Aug 2011 at 01:43 UTC
Media front allows me to set the mediafront preset on a per content type bases (or per view) but I have the need to do this on a per node basis.
Simple example would be to have node1 autoplay (so preset with autoplay) and node2 not autoplay but both node1&2 are the same content type.
Comments
Comment #1
travist commentedYou can just do this with some CCK and Content Templates.
Hope this helps.
Travis.
Comment #2
travist commentedChanging title for better search-ability...
Comment #3
that0n3guy commentedTravis,
Thanks for that. I didn't even think about that. I could even just put step 3 in the body of the node.
My current setup is w/ video & flowplayer modules w/ a small hack... I have it go along w/ a feature I built that makes it very simple for several clients to do this via node edit form and cck. The code above is a little over their heads. I may have to try and emulate it w/ a simple module. Thanks
Comment #5
that0n3guy commentedI thought I would post some documentation for this. It is working pretty sweeeet and exactly the way I want it to (basically). I changed to 'needs review' in case you wanted to look it over and add it to the official docs.
Setup:
- Create a content type with a filefiled and image field like you normally would.
- create a mediafront profile like you normally would
- also create a field called "video_playerpreset" (so its final machine name will be "field_video_playerpreset")
- Make it a "text" field of "select" type
- In the "PHP code" section (below the "Allowed values list") add this code:
- install the custom_formatters module (http://drupal.org/project/custom_formatters)
- create a new formatter
- user the "advanced editor"
- use this code:
- Modify the fields in the code to match your video, image, and preset fields
- save your new formatter
- Go to the "Display Fields" tab (yoursite.com/admin/content/node-type/[[yourcontenttypehere]]/display)
- select your new custom formatter for you video field
- hide (Don't exclude) the thumbnail field and preset field.
Done, create a new piece of content, upload video, thumbnail (optional) and select which preset you want for the video.
EDIT 7-29-10: changed up the custom_formatters code a littel so you just add the fields at the beginning (more newbie friendly). Also, added a check to see if there was actually a video added. If not, it does nothing instead of displaying "player not available"
Comment #6
travist commentedThanks! I added this to the http://www.mediafront.org documentation section, so hopefully it will be easy to find.
http://www.mediafront.org/documentation/drupalmediafront-osm-cms-integra...
Comment #7
that0n3guy commentedWow that was fast.
Thanks Man!
Comment #8
that0n3guy commentedI've been testing this some more and I noticed that my: $params['file'] or $params['image'] don't actually do anything. Its the nodeObj that is actually supplying the video info to the player.
This is ok except if I have multiple imagefields... mediafront just picks the first one w/ an image for the video thumbnail.
So my question would be, how do I specify (in my formatter) what fields I want to use?
Comment #9
travist commentedI think this is now fixed since within the fieldfields, you can just set the fields you do not wish to include as "None".
Comment #10
travist commentedComment #12
thebinaryworkshop commentedHas anyone got documentation on how to embed the player inside a node.tpl.php? I have a whole bunch of videos and I'm a bit worried of the performance penalty if the template has to be rendered from DB each time on node load. Atleast using APC on a node.tpl.php would result in a somewhat user experience.
Comment #13
bsenftner commentedDoes this suggestion still work? I have two MediaFront Presets defined, with Blocks and Pages that demonstrate their existence, yet Step 2's code always returns an empty array for me...
And that description for how to create a custom formatter is missing some critical information or is outdated with the current interfaces, because following it does not make sense. I've not used custom formatters before, and the creation step seems to be missing something. (Or maybe it's working, and the code from Step 2 returning an empty array is the issue...?
Comment #14
travist commentedThis should still work, but you most of the preset code was moved to the mediafront.preset.inc file within the includes folder of mediafront. Because of this, you may need to include that file before calling mediafront_preset_get_presets.
Hope this helps.
Travis.
Comment #15
bsenftner commentedStill not working. I placed your suggested code, resulting in this inside the CCK 'video_playerpreset' Text selection's PHP configuration:
Placing this same code inside the Devel module's 'Execute PHP' form also shows the final value of $options is an empty array. I also tried including the filefield and features include files to see if that made any difference (inside the Devel module's 'Execute PHP' form), but including those additional files does not... :/
-Blake
Comment #16
travist commenteddid you put some print statements within the mediafront_preset_get_presets file to make sure that it is getting called? If so, then this sounds like some good ol' fashioned debugging is in order to figure out why this function is not giving you what you want. I know for a fact this function works since I use it all over, so I am sure there is a reason why it is giving you back empty results.