Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » flv not showing

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 1707 Views
  • Guy Van Bael
    Avatar
    Community Member
    28 Posts

    flv not showing Link to this post

    Hi All,

    I hav Filedom up and working (local with Mamp). I can upload mp3 or flv, but instead of showin on the page, a link shows up. When i click the link, the mp3 plays in another window. When i click the flv link. Firefox ask to dowload.

    here's my code
    download.php
    <?php
    class Download extends DataObject
    {
       static $db = array (
          'Naam' => 'Text',
          'Omschrijving' => 'Text',
       );

       static $has_one = array (
          'Bijlage' => 'File',
          'DownloadPage' => 'DownloadPage'
       );

       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('Naam'),
             new TextareaField('Omschrijving'),
             new FileIFrameField('Bijlage')
          );
       }
    }

    ?>

    downloadpage.php
    <?php
    class DownloadPage extends Page
    {
       static $has_many = array (
          'Bijlagen' => 'Download'
       );

       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new FileDataObjectManager(
             $this, // Controller
             'Bijlagen', // Source name
             'Download', // Source class
             'Bijlage', // File name on DataObject
             array(
                'Naam' => 'Name',
                'Omschrijving' => 'Description',
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
          );
          
       
    $f->addFieldToTab("Root.Content.Downloads",$manager);
    return $f;
       }
    }
    class DownloadPage_Controller extends Page_Controller {

          function AllDownloads() {
          return $this->data()->Bijlagen();      
             
          }
       
       };

    ?>

    downloadpage.ss
    <div class="typography">
          <h2>$Title</h2>   
          $Content
          
       <% control allDownloads %>

       <a href="$Bijlage.Filename">$Bijlage.FileName - $Bijlage.Size</a>
       <p>$Omschrijving</p>
       <% end_control %>
    </div>

    Note: I can only use $Bijlage.Filename. When i use just $Bijlage, i get a server error

    Can somebody help me out.
    Thanks

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: flv not showing Link to this post

    Hi Guy,

    if you'd like to show the movie (flv) in an embedded player, you have to do a little more.

    For embedding a movie you have to use a player as container for these movies.

    E.g. http://www.longtailvideo.com/players/jw-flv-player/

    Download the files an put them e.g in /themes/<your-theme>/swf/*

    Untested Template Code:

    <% require javascript(http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js) %>

    <div class="typography">
    <h2>$Title</h2>
    $Content

    <% control allDownloads %>

    <p id="container_$Pos">Please install the Flash Plugin</p>

    <script type="text/javascript">
    var flashvars = { file:'$Bijlage.Filename',autostart:'false' };
    var params = { allowfullscreen:'true', allowscriptaccess:'always' };
    var attributes = { id:'player_$Pos', name:'player_$Pos' };

    swfobject.embedSWF('themes/<your-theme>/swf/player.swf','container_$Pos','480','270','9.0.115','false',
    flashvars, params, attributes);
    </script>
    <% end_control %>
    </div>

    This example should only demonstrate the principle .....

  • UncleCheese
    Avatar
    4085 Posts

    Re: flv not showing Link to this post

    If you cast your file as "FLV" or "MP3", then all you need is $YourFileObject.Player. It automatically includes all of that stuff above..

    ---------------
    Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: flv not showing Link to this post

    Ahh, good to know ....

    @UC - did you get my Email this week regarding my uploadify/swfupload problems ?

  • Guy Van Bael
    Avatar
    Community Member
    28 Posts

    Re: flv not showing Link to this post

    Hi UncleCheese,

    I tried to adress the attachments (a jpg, pdf, mp3 and flv file) (Bijlage) in my download.ss file as $Bijlage.Player, but no luck, nothing shows. (except for the link, cfr. the next line) Here's my code for the dowload.ss files. Can you tell me what i'm doing wrong. I also noticed that the there's no video icon in the cms next to the flv-file. The icon that shows up is a kind of a blank paper.

    <div class="typography">
          <h2>$Title</h2>   
          $Content
          
       <% control allDownloads %>
       $Bijlage.Player
       <a href="$Bijlage.Filename">$Bijlage.FileName - $Bijlage.Size</a>
       <p>$Omschrijving</p>
       <% end_control %>
    </div>

    Hope you guys can help me out and thanx for all the effort you put in this fantastic modulei

    guy

  • yug
    Avatar
    Community Member
    17 Posts

    Re: flv not showing Link to this post

    Hi UncleCheese

    I have seen you post this a few times. What exactly do you mean and where should we cast?

  • UncleCheese
    Avatar
    4085 Posts

    Re: flv not showing Link to this post

    You have to cast the File relation as FLV, not File..

    $has_one = array (
    'SomeFile' => 'FLV'
    );

  • yug
    Avatar
    Community Member
    17 Posts

    Re: flv not showing Link to this post

    Yeah, but if you do that "SomeFile" cannot be say mp3
    In your screencast you just use the type file and it handles both flv and mp3

    1707 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.