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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Preview: DataObjectManager module

Go to End

379 Posts   75657 Views


Community Member, 215 Posts

3 April 2009 at 2:25pm

Hi there, just more info of the bug reported a post above. I have tried on another OSX system, the popup worked as expected in Safari and in Firefox the popup appeared but only contained the statement "I can't handle sub-URLs of a CMSMain object."


Community Member, 49 Posts

3 April 2009 at 3:11pm

@ howardgrigg, I had this same issue and can't for the life of me remember what was causing it. I ended up fixing it though, it was something I was doing wrong in the code. I'll do my best to remember what it was. Good luck!

Ben Gribaudo

Community Member, 181 Posts

4 April 2009 at 7:30am

Edited: 04/04/2009 7:30am

Cause of the issue mentioned in my post of 1 April 2009 at 10:03am:

Using the line from trunk, the pop-up's save button works correctly; with the line from nestedurls, it does not.



My post of 1 April 2009 at 10:03am:
I'm running revision 103 of DataObjectManager against revision 73881 of trunk. When I click the "save" button on the "add" pop-up window, the object I'm trying to add never gets saved to the database. Instead, I get sent to some kind of page that has an add link and a search box, etc.

The "add" pop-up window's form tag is as follows:
<form id="DataObjectManager_Popup_AddForm" action="admin/EditForm/field/Articles?ctf[Articles][per_page]=10&ctf[Articles][showall]=0&ctf[Articles][sort]=Created&ctf[Articles][sort_dir]=DESC&ctf[Articles][search]=&ctf[Articles][filter]=" method="post" enctype="application/x-www-form-urlencoded">

Is that the correct action? It looks funny to me.

Aaron Brockhurst

Community Member, 30 Posts

4 April 2009 at 9:10am

Hi Uncle Cheese

Fantastic work! The DataObjectManager is just what I needed.

Do you have an example of how to setup ManyManyDataObjectManager? I want to use it to enable users to select images to go in the right column on the page and have have the ability to have different images on everypage. I might have missed something but when I use DataObjectManager it puts the same objects on every page.




Forum Moderator, 4102 Posts

4 April 2009 at 9:19am

Edited: 04/04/2009 9:19am

Hi, Aaron.

Great use of the DataObjectManager. I'd recommend using a ManyManyFileDataObjectManager if I were you, since it will display the images in a grid for you, as well as streamline the upload process.

If you have the many_many relation set up correctly, it should be the same as a ManyManyComplexTableField, only with one more argument.

new ManyManyFileDataObjectManager(
'Image' // The fieldname on the $has_one array of your MyImage dataobject.
array( // headers...

You can read more in the documentation in the SS wiki.


Community Member, 165 Posts

4 April 2009 at 10:06am

Uncle Cheese. Thank you for all your hard work and help.

I would like to use the Testimonials page type to manage testimonials. I have set up the page so that I can add testimonials and I can see the database table where they are stored. What I don't know how to do is randomly grab a Testimonial and display it on any give page on the site. My guess is that in the Page_Controller I would have a function that could select a random Testimonial from the database and display the Testimonial Content and Author on my page. I don't need a page that shows all of the Testimonials.


Forum Moderator, 4102 Posts

4 April 2009 at 10:13am


function RandomTestimonial()
return DataObject::get_one("Testimonial", null, true, "RAND()");

FYI: Please do not rely on the example code included with dataobject_manager. I'll be removing it soon. You can recreate it in mysite/code if you want.

Amir Mostofi

Community Member, 59 Posts

8 April 2009 at 1:55pm

I have a simple question regarding the display of content in a template. I'm using FileDataObjectManager and my files are as follows:

class Partner extends DataObject
static $db = array (
'Name' => 'Text',
'URL' => 'Text'

static $has_one = array (
'Logo' => 'File',
'PartnerPage' => 'PartnerPage'

public function getCMSFields_forPopup()
return new FieldSet(
new TextField('Name'),
new TextField('URL'),
new FileIFrameField('Logo')

class PartnerPage extends Page
static $has_many = array (
'Partners' => 'Partner'

public function getCMSFields()
$f = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, // Controller
'Partners', // Source name
'Partner', // Source class
'Logo', // File name on DataObject
'Name' => 'Name',
'URL' => 'URL'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause

// If undefined, all types are allowed. Pass with or without a leading "."

// Label for the upload button in the popup
$manager->setBrowseButtonText("Upload (JPG or GIF only)");

// 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.Partners", $manager);

$f->removeFieldFromTab('Root.Content', 'HeaderImage');

return $f;


class PartnerPage_Controller extends Page_Controller
<% if Partners %>
<div id="partners"><div class="container">
<div id="partner-logos">
<% control Partners %>
<li class="partner-logo"><a href="#" title="$Name" style="background-image: url('$Logo.URL')"><span>$Name</span></a></li>
<% end_control %>
</div></div><!-- end #partners -->
<% end_if %>

Can anyone tell me why the above template file does not return any Partners, when in the CMS I clearly have added records using dataobjectmanager and I can see them under the Partners tab in the CMS?

Go to Top