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, biapar, Willr, Ingo, swaiba

PassedID can not be checked ?!?


Go to End
Reply


2 Posts   1154 Views

Avatar
markus85

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:

SpielerHolder.ss:

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

DetailSpieler.ss

<% control showSpieler %>

		$Vorname $Nachname


	<% end_control %>

DetailSpieler.php:

 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);

 		}
 		else{
 			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:
"http://localhost/knights/DetailSpieler/5"

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

Avatar
markus85

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'];
		if(is_numeric($auftragsID))
			return DataObject::get_by_id("Auftrag", "$auftragsID");
	}