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

Audio and video not displaying in the front end


Go to End
Reply


598 Views

Avatar
ravik

Community Member, 10 Posts

3 July 2012 at 7:52pm


hi sir,

I am a new for this platform,i have installed silverstripe v2.4.7 and it is working fine.
now i want to display audio and video in my website. for that i used the code below

Resource.php (I put this page into mysite/code/)
-----------------
<?php
class Resource extends DataObject
{
static $db = array (
'Name' => 'Text',
'Description' => 'Text',
'Category' => "Enum('Industry, Finance, Education')"
);

static $has_one = array (
'Attachment' => 'File',
'ResourcePage' => 'ResourcePage'
);

public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new TextareaField('Description'),
new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
new FileIFrameField('Attachment')
);
}
}

ResourcePage.php (I put this page into mysite/code/)
----------------------------
<?php
class ResourcePage extends Page
{
static $has_many = array (
'Resources' => 'Resource'
);

public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, // Controller
'Resources', // Source name
'Resource', // 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
);
$f->addFieldToTab("Root.Content.Resources",$manager);
return $f;
}
}
class ResourcePage_Controller extends Page_Controller {
}

ResourcePage.ss (I put this page into theme/blackcandy/template/layout)
-------------------------
<div id="primaryContent" class="clearfix">
<div class="innerpad">
<h2>$Title</h2>
<% if URLSegment = Security %>
<% include WelcomeMessage %>
<% else %>
$Content
<% control Resources %>
<h3>$Name</h3>
<p>$Description</p>
<% control Attachment %>$Player(640,480)<% end_control %>
<% end_control %>

<% end_if %>
$Form
</div>
</div>
<div id="secondaryContent">
<div class="innerpad">
<div id="secondarynav">
<ul>
<% if Children %>
<li><a href="$Link" class="current">$Title Overview</a></li>
<% else_if Level(2) %>
<li><a href="$Parent.Link">$Title Overview</a></li>
<% end_if %>
<% control Menu(2) %>
<li><a class="$LinkingMode" href="$Link">$MenuTitle</a></li>
<% end_control %>
</ul>
</div>
<% include Callout %>
</div>
</div>
<div id="sideContent">
<div class="innerpad">
</div>
</div>

but the things is when i uploaded the file audio or video in the cms no problem, but when i go to front end there
Name, Description are displaying but the attachement file like audio and video is not displaying.

Please its my humble request, because from past one month i was spending time for this problem only.
please please give me the solution for this problem.