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

Show only related objects

Go to End

11 Posts   2700 Views


Forum Moderator, 4102 Posts

26 June 2009 at 9:46am

Here's a random shot in the dark..

$fields->addFieldToTab("Root.Content.Students", new LiteralField('list', $this->getManyManyComponents('Students')->UL()));

No idea if that will work, but worth a shot!


Community Member, 4 Posts

25 December 2009 at 3:14am

Sorry for necroposting, but i had the same need to show only related objects. I have many EventPages and many Members. Each of members can be assigned to each EventPage, but there are about 1,000 users and usually about 200-300 are assigned. So I did the next:


class EventPage extends Page
static $many_many = array(
'Members' => 'Member'

public function getCMSFields() {
$fields = parent::getCMSFields();

$sqlQuery = new SQLQuery();
$sqlQuery->select = array('MemberID');
$sqlQuery->from = array("EventPage_Members");
$sqlQuery->where = array("EventPageID=".$this->ID);
$rawSQL = $sqlQuery->sql();
$result = $sqlQuery->execute();
foreach($result as $row){
$query .= $row[MemberID]." OR MemberID=";
$query .= $row[MemberID];

$modulesTablefield = new ManyManyComplexTableField(
'Name' => 'Name',
'Email' => 'Email'


$fields->addFieldToTab( 'Root.Content.Subscribers', $modulesTablefield );

return $fields;

In Member.php from sapphire i also made some changes like
static $belongs_many_many = array(
'Events' => 'EventPage'

What is my code doing? It takes all MemberID which are related to the current EventPage from many_many table which in my case named EventPage_Members and had columns MemberID, EventPageID. Then I made a $query with that MemberIDs which is used as filter in ManyManyComplexTableField constructor.

This solves only one half of problem - i couln't remove that markers... Hope others could =)


Forum Moderator, 4102 Posts

25 December 2009 at 3:44am

I'm actually just about to release a bunch of new features for MMDOM, and one of them is a "related objects only" checkbox. I don't know if that will help you or not.

Go to Top