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

Getting an ID to bass into get_by_id


3 Posts   367 Views


21 October 2011 at 4:30am Community Member, 146 Posts


Let me start with my code

public static $belongs_to = array(
'Event' => 'Event',
'Team' => 'Team'

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root.Content.Main', 'MenuTitle');
$fields->removeFieldFromTab('Root.Content.Main', 'Title');
$fields->removeFieldFromTab('Root.Content.Main', 'Content');

$EventID = DataObject::get_by_id('Event',$this->EventID);

$oData = (DataObject::get('Team','`Event_Teams`.EventID =' + $EventID,'','LEFT JOIN `Event_Teams` ON `Event_Teams`.TeamID=`Team`.ID ',''));
if ($oData) {
$CategoriesSource = $oData->toDropDownMap('ID','Name');
} else {
// no categories there yet, might put a literalfield to tell the user

What I am trying to do here is pass the EventID to the filter so I only see teams that are entered into the Event (by filter by eventID and then joining teams in the Event_teams table).

However I get an error that EventID is null... (or to that effect)... I am not sure how to correctly reference EventID so that I get the current event thats selected in the CMS...

Any ideas?



22 October 2011 at 6:38am 4085 Posts

What's the + for in your where clause?


24 October 2011 at 9:09pm Community Member, 146 Posts

disclaimer - im new to PHP, so i thought that would do the same as & in classic ASP... i didnt know how to include the variable in my select statement. So 2 probs here I guess...

1. How do I get the ID
2. How do i then include that in the where clause...

thanks for any help or where I can go to find the right answer :)