Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » New Feature: Audio and Video

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Go to End
Author Topic: 23573 Views
  • thrax
    Avatar
    Community Member
    32 Posts

    Re: New Feature: Audio and Video Link to this post

    Anyone got any advice? lol

  • Shawn Parr
    Avatar
    Community Member
    60 Posts

    Re: New Feature: Audio and Video Link to this post

    Check out this page: http://doc.silverstripe.com/doku.php?id=error-handling

    Turn on the SS error handling, reload a page/popup with the error, and check the log. If it is something that you aren't sure of what it means/where to find it, post back here with the info and we will try to help.

    Sometimes the errors can be tricky to navigate, as the log usually points you to a core file where the function is currently running, and you have to infer where in your code is the issue that causes the error.

    I'll also mention that I just had an issue with a module/page I made that would put up errors with an ImageField, and the site would also put up the SS error when I tried to go into Files & Images. I feared a database issue, but eventually fixed it by removing the module folder, running /dev/build, putting the module folder back, then /dev/build again. That to me seems like witchcraft (especially since the /dev/build didn't show any real changes), but it worked.

  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    Thanks, Shawn,

    Yes, it's almost always a PHP syntax error or a Silverstripe specific error, such as referring to an object that doesn't exist, or using a DOM for a relationship that isn't set up right.

    Much easier to troubleshoot once you have a verbose error, though.

  • thrax
    Avatar
    Community Member
    32 Posts

    Re: New Feature: Audio and Video Link to this post

    After turning on logging the page creation give me this

    Warning: error_log(..//my/logfile/path) [function.error-log]: failed to open stream: No such file or directory in /var/www/sapphire/dev/Debug.php on line 412
    There has been an error

    I've also removed and re-added page types and modules over and over and over

    At first I thought the above error was an error in being able to write a log file (which I assume it still is), but I've change the path (without '/', to custom paths, to about 20 different things) and always for the same error - and no log file on the file system.

    :'( help? lol

  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    Probably easier to turn on error reporting to email rather than figure out the file i/o error.

  • Fran
    Avatar
    Community Member
    8 Posts

    Re: New Feature: Audio and Video Link to this post

    Hi Uncle Cheese,
    I viewed your videos and read posts and refered to your template on using FileDataObject for my needs. Congrats! The dataObject module is a piece of Art. Any scoop with the new ss release integration? Myself, I will migrate when I'll know your modules will...

    Here's my issue: Basically I want to display videos on one page (controlled by pagination like in the FileDataObject in CMS ) and allow visitors to filter results by category. I ceated a template and videos attachment thumbnails are displayed with the category label. This is good news. I cannot figure out how to format the page similar to the CMS one.

    Where to start? Your comments on what folders and files should I duplicate in my theme/template to avoid messing up with the DataObject_Manager module. I use it in other pages as well. Any hint will be appreciated.
    Thanks for your support
    Cheers,

  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    Happy to help you out, but just so I don't waste any time writing code you already have, could you give me an idea of what you have working right now?

    "I cannot figure out how to format the page similar to the CMS one."

    So you have videos displaying on your template, and everything works, but you just need to figure out how to filter by category?

    Es-tu vraiment francais? Je peux essayer de fournir les instructions en francais si tu veux.

  • Fran
    Avatar
    Community Member
    8 Posts

    Re: New Feature: Audio and Video Link to this post

    Salut Oncle Fromage (sounds odd in french, doesn't it?). Oui je suis Canadien français originaire du Québec. Je vis maintenant au BC. How about you? Your written french looks good anyway. Lets do this in english for better follow-up, ok? Excuse my frenglish if I am not clear, ok. Anytime you want to practice my native language, go ahead mon oncle...
    Said this, let me detail my request:
    In summary, the video gallery will display a filter by category dropdown list . Default should be Show All. Results will also be controlled by the pagination routine. Visitor will be able to select a specific category from the dropdown. Video Data displayed is (Name, Descr and video length, date created and finally the video thumbnail) in a list format only.
    So far, I am using the filter function found in another post. It looks like:
    The video class looks like the following code:

    class Video extends DataObject
    {
       static $db = array (
          'Name' => 'Text',
          'Description' => 'Text',
          'Category' => "Enum('cat1, cat2, cat3')"
       );
       
       static $has_one = array (
          'Attachment' => 'File',
          'VideoPage' => 'VideoPage'
       );
       
       public function Categories()
       {
          $cats = new DataObjectSet();
          foreach(singleton($this->class)->dbObject('Category')->enumValues() as $category) {
             $cats->push(new ArrayData(array(
                'Title' => $category,
                'Videos' => $this->Videos("Category = '$category'")
             )));
          }
          return $cats;
       }
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('Name'),
             new TextareaField('Description'),
             new DropdownField('Category','Category', singleton('Video')->dbObject('Category')->enumValues()),
             new FileIFrameField('Attachment')
          );
       }
    }

    Then currently, the video page class is coded as followed:

    class VideoPage extends Page
    {

       static $has_many = array (
          'Videos' => 'Video'
       );
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new FileDataObjectManager(
             $this, // Controller
             'Videos', // Source name
             'Video', // Source class
             'Attachment', // File name on DataObject
             array(
                'Name' => 'Name',
                'Description' => 'Description',
                'Category' => 'Category'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
          );
          $manager->setFilter(
             'Category', // Name of field to filter
             'Filter by Category', // Label for filter
             singleton('Video')->dbObject('Category')->enumValues() // Map for filter (could be $dataObject->toDropdownMap(), e.g.)
          );
          
          // If undefined, all types are allowed. Pass with or without a leading "."      
          $manager->setAllowedFileTypes(array('flv','mov','mpeg','mpg','avi'));
          
          // Label for the upload button in the popup
          $manager->setBrowseButtonText("Upload");
          
          // In grid view, what field will appear underneath the icon. If left out, it defaults to the file title.
          $manager->setGridLabelField('Name');
          
          // Plural form of the objects being managed. Used on the "Add" button.
          // If left out, this defaults to [MyObjectName]s
          $manager->setPluralTitle('Videos');
                   
          $f->addFieldToTab("Root.Content.Videos", $manager);

          return $f;
       }
    }
    Class VideoPage_Item extends ComplexTableField_Item {
       function __construct(DataObject $item, VideoPage $parent, $start)
       {
          parent::__construct($item, $parent, $start);
       }
       
       function Fields() {
          $fields = parent::Fields();
          $widths = $this->parent->getColumnWidths();
          if(!empty($widths)) {
             foreach($fields as $field) {
                $field->ColumnWidthCSS = sprintf("style='width:%f%%;'",($widths[$field->Name] - 0.1));
             }
          }
          return $fields;      
       }
       
    }

    class VideoPage_Controller extends Controller

       // Filter by Category
       function FilteredVideos()
       {
          $filter = Director::urlParam('Action');
          return $filter ? $this->Videos("Category = '$filter'") : $this->Videos();

       }   
    }


    As you can see the function FilteredVideos is part of the controller. I don't really quite understand these 2 lines. Maybe you'll explain.

    And finally the layout template (located in the themes dir:

    <% control FilterVideos %>
    <div>
       <h4>$Name</h4>
       <p>$Description</p>
       <p><b>Category:</b> $Category</p>
       <% control Attachment %>
          $VideoPopup(80,60)
          <h6><b>Published Date:</b> $Created.Nice</h6>
       <% end_control %>      
    </div>
    <% end_control %>

    So far so good...but this is not what I want. In this matter a have to create a page for each category. I thought that this can be done in a single page and let the visitor select the video category he wants. Also for the site publisher, he can upload any video from 1 page location only.
    The final result should be as I explained at the beginning with the dropdown and the results data displayed in a list format.

    Merci

    This is

    23573 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
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.