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?