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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Solved:drag and drop feature of sorting in video page


Go to End


3 Posts   1155 Views

Avatar
Rishi

Community Member, 97 Posts

6 February 2010 at 12:52am

Edited: 12/02/2010 2:59am

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

Community Member, 81 Posts

6 February 2010 at 2:01am

Hi Rishi

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

.../dev/build?flush=1

Avatar
Rishi

Community Member, 97 Posts

12 February 2010 at 2:05am

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