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, simon_w

Bug while calling the ManyManyDataObjectManager


Go to End
Reply

9 Posts   2152 Views

Avatar
brokemeister

12 June 2009 at 11:34pm Community Member, 30 Posts

I Just wanted to display a ManyMany-Relation with the ManyManyDataObjectManager.

But I always get following error:
Fatal error: Access to undeclared static property: ViewableData::$many_many in ~\sapphire\core\Object.php(376) : eval()'d code on line 1

My DataObject looks like this:
class ContentDataObject extends DataObject {
   
   static $db = array (
      "Title" => "Varchar(255)",
      //...
   );
   

   static $many_many = array (
      "Connections" => "ArticleDataObject",
   );
   
      
   static $belongs_many_many = array (
      "ConnectionsBelongs" => "ContentDataObject",
   );
}

The Manager in the Page looks like this (If I replace "ManyManyDataObjectManager" with "DataObjectManager" is working):
$manager = new ManyManyDataObjectManager(
         $this,
         'CurrentContent',
         'ContentDataObject',
         $this->getListedFields(),
         'getCMSFields_forPopup'
      );
      return $manager;

System:
SS 2.3.1
dataobject_manager r117

Any ideas how to solve the error?

Cheers,

Malte

Avatar
UncleCheese

13 June 2009 at 1:24am 4085 Posts

Looks like you've probably set up your model wrong. Paste in all of your code for the Page object.

Avatar
brokemeister

13 June 2009 at 2:22am Community Member, 30 Posts

Hi UncleCheese,

thanks for your fast reply.
Here is the PageObject...

class MagazinDataPage extends DataPage
{
   static $db = array (
   );
   
   static $has_many = array (
      'Content' => 'ContentDataObject'
   );
   
   static $allowed_children = array("MagazinDataPage");
   
   public function getCMSFields($cms) {
      $fields = parent::getCMSFields($cms);
//      $fields->addFieldToTab("Root.Content.Current", $this->getCurrentContentManager());
//      $fields->addFieldToTab("Root.Content.LastChanged", $this->getStoreManager());
//      $fields->addFieldToTab("Root.Content.Archiv", $this->getZIPManager());
      $fields->addFieldToTab("Root.Content.All", $this->getAllContentManager());
      return $fields;
   }
   
   protected function getAllContentManager() {
      $manager = new ManyManyDataObjectManager(
         $this,
         'CurrentContent',
         'ContentDataObject',
         $this->getListedFields(),
         'getCMSFields_forPopup'/*,
         "MagazinDataPageID = {$this->ID}"*/
      );
//      $manager->setParentClass('MagazinDataPage');
      $manager->setFilter("ClassName", "ContentType", ContentDataObject::getContentTypeClasses());
      return $manager;
   }
   
   protected function getListedFields() {
      return array(
            "ClassName" => "ContentType",
            "Title" => "Titel",
            "ShowOn" => "Erscheinungsdatum",
            "Disabled" => "Versteckt",
            "HideOn"=> "Ausblendungsdatum"
         );
   }
   
}

class MagazinDataPage_Controller extends DataPage_Controller
{

}

Cheers,

Malte

Avatar
UncleCheese

13 June 2009 at 3:16am 4085 Posts

Yeah, you've set up your model wrong.

Page => $many_many DataObjects
DataObject => $belongs_many_many Pages

ManyManyDOM

$this,
'NameOfDataObjects',
'DataObjectClassName'

Avatar
brokemeister

13 June 2009 at 7:23pm Community Member, 30 Posts

But than my Konzept does not work.

I would like to have
Page => $has_many DataObjects
DataObject => $has_one Page

DataObject => $many_many DataObjects
DataObject => $belongs_many_many DataObjects

So a DataObect is stored in one Page.
And all DataObjects can be connected to each other.

How can I solve this? I don't want to have each DataObject as Page or did I get something wrong?

Cheers,

Malte

Avatar
UncleCheese

14 June 2009 at 9:43am 4085 Posts

If you're relating dataobjects to a dataobject, you need to use a CheckboxSetField in your popup form. The ManyManyDataObjectManager is used for attaching DataObjects to Pages. If those DataObjects have their own sets of relationships, they are handled in the edit window for each of those objects -- not in the MMDOM.

Avatar
brokemeister

17 June 2009 at 9:35pm Community Member, 30 Posts

Thanks for your help.

Generally it works, but if you have more than 20 Objects available. It's not managable anymore.
I have to rework this part of my concept.

Avatar
UncleCheese

18 June 2009 at 1:46am 4085 Posts

You MIGHT have some luck with the MultiSelectField here http://www.silverstripe.org/multiselectfield-module/ which is built for this sort of thing. I'd say there's a 50% chance it will fail in a popup window, though.

Worth a shot!

Go to Top