Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

[Solved] Upload movies via backend


Reply

5 Posts   411 Views

Avatar
StefanDpunkt

15 October 2013 at 4:09am Community Member, 14 Posts

Hi,

I want to upload movies via backend.
The films are of type "file"

public static $ has_one = array (
"mp4" => "File"
"m4v" => "File"
"ogv" => "File"
"webm" => "File"
);
[/ code]
Unfortunately, I get the following error!

[User Error] Uncaught Exception: Object-> __call (): the method 'fortemplate' does not exist on the 'File'
[/ code]
I can not do anything with this error message, so, anyone has an idea?

Avatar
zenmonkey

15 October 2013 at 5:18am Community Member, 528 Posts

Can you provide some more info, where are you getting this error? When uplaoding files, or trying to display them in the fornt end?

Avatar
StefanDpunkt

15 October 2013 at 8:17pm (Last edited: 15 October 2013 8:18pm), Community Member, 14 Posts

Hallo zenmonkey,

i get this error in the front end, in the back end, i get no error. Uploading without errors.

Code Front end

<% loop Movies %>
<div id="clip0" class="easyhtml5video" style="position:relative;max-width:640px;">
<video id="video0" autoplay="autoplay" poster="$Startbild.Filename" style="width:100%" title="" loop="loop" onended="var v=this;setTimeout(function(){v.play()},300)">
<source src="$webm" type="video/webm" />
<source src="$mp4" />
<source src="$ogv" type="video/ogg" />
<source src="$m4v" type="video/mp4" />
<object type="application/x-shockwave-flash" data="$Startbild.Filename" width="640" height="480" style="position:relative;">
<param name="movie" value="../flashfox.swf" />
<param name="allowFullScreen" value="true" />
<param name="flashVars" value="autoplay=true&amp;controls=false&amp;fullScreenEnabled=false&amp;posterOnEnd=true&amp;loop=true&amp;poster=$Startbild.Filename&amp;src=$m4v" />
<embed src="..flashfox.swf" width="640" height="480" style="position:relative;" flashVars="autoplay=true&amp;controls=false&amp;fullScreenEnabled=false&amp;posterOnEnd=true&amp;loop=true&amp;poster=$Startbild.Filename&amp;src=$m4v"   allowFullScreen="true" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_en" />
<img alt="" src="$Startbild.Filename" style="position:absolute;left:0;" width="100%" title="Video playback is not supported by your browser" />
</object>
</video>
</div>
<% end_loop %>
[/end]

Avatar
zenmonkey

16 October 2013 at 1:41am (Last edited: 16 October 2013 1:42am), Community Member, 528 Posts

Okay as I suspected. $webm, $ogv etc returns the file Object (the whole database record), you want to get a property off it. You'll need to use $webm.Filename. I find if the solution is video.js based you should use $webm.AbsoluteURL otherwise the falsh fallback can fail.

As an aside I would also wrap each of them in a if statement just in case the end user fails to upload one of them

<% if $webm %><source src="$webm.AbsoluteURL" type="video/webm" /><% end_if %>

Avatar
StefanDpunkt

16 October 2013 at 2:12am Community Member, 14 Posts

It' s work!
Many, many, many THX!

!!!And I still have a bit more understood by SilverStripe!!!