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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Solved:drag and drop feature of sorting in video page


Reply

3 Posts   766 Views

Avatar
Rishi

6 February 2010 at 12:52am (Last edited: 12 February 2010 2:59am), Community Member, 97 Posts

hello
i have a video page working fine on my site , thanks to UC, i would like to have an option of drag and drop sorting option in the admin panel,the code is

Video.php
<?php

class Video extends DataObject
{
   static $db = array (
      'Title' => 'Varchar(100)',
      'Description' => 'Text'
   );
   
   static $has_one = array (
      // Make sure this comes first
      'VideoPage' => 'VideoPage',
/**
* This relationship could be as simple as 'Video' => 'File' provided
* FileDataObjectManager::$upgrade_video is true (defaults to true).
* However, if we know the page will only contain videos, we can simplify things by
* using a direct relationship to FLV. This will give us the benefit of not having
* to worry about the allowed_file_types setting.
*
* To make this an audio resource, set the relationship to the MP3 class, e.g.
* 'AudioFile' => 'MP3'. Audio files are also subject to automatic upgrades, however,
* based on FileDataObjectManager::$upgrade_audio. (true by default).
*
*/
      'Video' => 'FLV'
   );
   
}
?>

VideoPage.php

<?php
/**
* Before getting started, be sure to test your FFMPEG installtion by adding:
* FLV::echo_ffmpeg_test();
* to your _config.php!
*
*/

class VideoPage extends Page
{
   static $has_many = array (
      'Videos' => 'Video'
   );
   
   public function getCMSFields()
   {
      $fields = parent::getCMSFields();
      $fields->addFieldToTab("Root.Content.Videos", new FileDataObjectManager(
         $this,
         'Videos',
         'Video',
         'Video',
         array('Title' => 'Title', 'Description' => 'Description'),
         new FieldSet(
            new TextField('Title'),
            new TextareaField('Description')
         )
      ));
      return $fields;
   }
}

class VideoPage_Controller extends Page_Controller
{

}

?>

VideoPAge.ss

   <% control Videos %>
      <div class="link">
         <div class="description">
            <h3>$Title</h3>
            <p>$Description</p>
         </div>
         <div class="resource">
         
$Video
            

            
         </div>
      </div>
   <% end_control %>

thank you in advance

Avatar
lerni

6 February 2010 at 2:01am Community Member, 80 Posts

Hi Rishi

add this to your /mysite/_config.php
SortableDataObject::add_sortable_classes(array('Video'));

.../dev/build?flush=1

Avatar
Rishi

12 February 2010 at 2:05am Community Member, 97 Posts

hello lerni
thanks for your help,it really solved my problem.thanks once again