2580 Posts in 695 Topics by 540 members
Data Model Questions
SilverStripe Forums » Data Model Questions » PassedID can not be checked ?!?
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 789 Views |
-
PassedID can not be checked ?!?

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?
-
Re: PassedID can not be checked ?!?

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");
}
| 789 Views | ||
|
Page:
1
|
Go to Top |

