7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » $many_many DataObjects no longer displayed
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 1799 Views |
-
$many_many DataObjects no longer displayed

3 May 2011 at 3:09am
I have a class
<?php
class Brochure extends File{static $db = array (
'Title' => 'Text',
'Name_de' => 'Text',
'Name_en' => 'Text',
"ShowInSearch" => "Boolean"
);static $belongs_many_many = array(
'Pages' => 'Page'
);
static $singular_name = 'Brochure';
static $plural_name = 'Brochures';
static $defaults = array (
'ShowInSearch' => 0
);
public function getCMSFields_forPopup()
{
$filefield = new FileUploadField('Parent','PDF');
$filefield->removeFolderSelection();
$filefield->uploadFolder = 'brochures/';
return new FieldSet(
new TextField('Name_de'),
new TextField('Name_en'),
$filefield
);
}
}
?>and a PageType that has a many_many relation to the brochures
class ReferencePage extends Page {
....static $many_many = array (
'Brochures' => 'Brochure',
);function getCMSFields() {
$fields = parent::getCMSFields();...
// Adding Brochures
$brochurefilemanager = new ManyManyFileDataObjectManager(
$this, // Controller
'Brochures', // Source name
'Brochure', // Source class
'Parent', // File name on DataObject
array(
'Name' => 'Name'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$brochurefilemanager->default_view = 'list';
$brochurefilemanager->setAllowedFileTypes(array('pdf'));
$brochurefilemanager->allowUploadFolderSelection = false;
$brochurefilemanager->setUploadFolder('assets/brochures/');
$fields->addFieldToTab("Root.Content.AttachedFiles",$brochurefilemanager);....
}
But these DataObjects are no longer displayed within the backend or the frontend. I looked for them in my database. Tables are there and okay. Does anyone see the problem? Thank you for your help. SS-Version is 2.4.5 with latest version of the DataObject_Manager Module.
-
Re: $many_many DataObjects no longer displayed

3 May 2011 at 9:46am
Hi Oleze,
I think your many_many relationship should be:
static $belongs_many_many = array(
'Pages' => 'ReferencePage'
);Aram
www.SSBits.com - Your one stop SilverStripe learning resource.
-
Re: $many_many DataObjects no longer displayed

3 May 2011 at 9:05pm
Thank you Aram,
the problem is:Those Brochures also belong to VehiclePages and others. Do you think that's the problem? Do I need e many_many relation for every Page type a Brochure belongs to?
-
Re: $many_many DataObjects no longer displayed

3 May 2011 at 10:46pm
Hi Oleze,
You either need to add the many_many static to Page.php along with the DOM, or you need to add a number of belongs_many_many in the DataObject, otherwise SS is gonna get confused because you are telling it it belongs to a relationship on the Page class, but there is no relationship defined on that Class.
Aram
www.SSBits.com - Your one stop SilverStripe learning resource.
-
Re: $many_many DataObjects no longer displayed

3 May 2011 at 11:34pm
Okay, I changed my code to:
static $belongs_many_many = array(
'ReferencePages' => 'ReferencePage',
'VehiclePages' => 'VehiclePage'
);I still can't see the DataObjects (Brochures) on my ManyManyFileDataObjectManager in the backend. The tables and ID's match each other for all relations in my database....
-
Re: $many_many DataObjects no longer displayed

3 May 2011 at 11:50pm
What happens if you create a new one? Does it show in the DOM?
What is the db table called?
Aram
-
Re: $many_many DataObjects no longer displayed

4 May 2011 at 2:51am
Nope, doesn't show up. Tables are called "ReferencePage_Brochures" and "VehiclePage_Brochures". Brochures are saved in the "Brochure" table which joins "File". Everything as it should be, I think.....
-
Re: $many_many DataObjects no longer displayed

4 May 2011 at 3:59am
ManyManyFileDOM doesn't manage File or File subclasses. It manages DataObject subclasses that have a file relation within them.
| 1799 Views | ||
| Go to Top | Next > |

