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, Ed, biapar, Willr, Ingo, swaiba

New Feature: Audio and Video

Go to End

150 Posts   31605 Views


Community Member, 32 Posts

17 June 2009 at 6:16pm

Anyone got any advice? lol

Shawn Parr

Community Member, 60 Posts

18 June 2009 at 1:28am

Check out this page:

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.


Forum Moderator, 4102 Posts

18 June 2009 at 1:39am

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. :-)


Community Member, 32 Posts

18 June 2009 at 11:03am

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


Forum Moderator, 4102 Posts

20 June 2009 at 3:45am

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


Community Member, 8 Posts

21 June 2009 at 3:52pm

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


Forum Moderator, 4102 Posts

22 June 2009 at 8:32am

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. :-)


Community Member, 8 Posts

23 June 2009 at 3:27am

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
				'Name' => 'Name', 
				'Description' => 'Description', 
				'Category' => 'Category'
			), // Headings 
			'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
			// Filter clause
			// Sort clause
			// Join clause
			'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 "."		
		// Label for the upload button in the popup
		// In grid view, what field will appear underneath the icon. If left out, it defaults to the file title.
		// Plural form of the objects being managed. Used on the "Add" button.
		// If left out, this defaults to [MyObjectName]s
		$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 %>
	<p><b>Category:</b> $Category</p> 
	<% control Attachment %> 
		<h6><b>Published Date:</b> $Created.Nice</h6>
	<% end_control %>		
<% 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

Go to Top