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.

Data Model Questions /

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

PassedID can not be checked ?!?

Go to End

2 Posts   1233 Views


Community Member, 12 Posts

3 April 2009 at 7:36pm

Hello folks, that´s my situation:
I have a page called "SpielerHolder" containing many DataObjects "Spieler". If you click on one of these "Spieler" you click on a link to "DetailSpieler" where some details are shown.

I created a link and added the $ID of the selected "Spieler"
In the page "DetailSpieler" I want to get the whole DataObject from the Page_Controller but this doesnt work.
Here is the code:

<td><a href="DetailSpieler/$ID">$Vorname $Nachname</a></td>

<% control showSpieler %>

		$Vorname $Nachname

	<% end_control %>


 class DetailSpieler_Controller extends Page_Controller{

 	function showSpieler(){

 		if($id = Director::urlParam('ID')) {		// Wir haben eine ID erhalten
			return DataObject::get_by_id("Spieler", $id);

 			return DataObject::get_by_id("Spieler",1);



In the if-clause I check whether there is an ID or not, the code in this clause is never been executed.
I always get the DataObject in the else-clause.

Here is an example URL:

Can anyone give me a hint why the if-clause isn´t executed?


Community Member, 12 Posts

6 April 2009 at 3:41am

Here is a working code snippet for the prob. above

function getAuftrag(){
		$Params = Director::urlParams();
		$auftragsID = $Params['Action'];
			return DataObject::get_by_id("Auftrag", "$auftragsID");