3063 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1067 Views |
-
Fetching (has_one) related Date

29 May 2009 at 3:38am
Hi,
i'm new to SS but i like it.
In my first training-Project I handle 2 Models within Admin an new Page Type.
Event, Location
(Event has_one Location)
Works Perfectly.In detail-view i would like to fetch the details of the Event including the details of the Location
Controller:
function details()
{
$event_id = (int)Director::urlParam('ID');
$event = DataObject::get_by_id('Event', $event_id);
/.......
}
[/code}View:
<% if Eventdetails %>
<dl>
<% control Eventdetails %>
<!-- Data from Model "Event" -->
<dt>Datum:</dt><dd>$Date.Format(d.m.Y)</dd>
<dt>Start:</dt><dd>$Start</dd>
<dt>Ende:</dt><dd>$End</dd>
<!-- Additional Info from Model "Location" should go here -->
<dt>Street:</dt><dd>$Street</dd>
<dt>Zip:</dt><dd>$Zip</dd>
<dt>Phone:</dt><dd>$Phone</dd>
<% end_control %>
</dl>
<% end_if %> -
Re: Fetching (has_one) related Date

29 May 2009 at 3:41am
Sorry, incomplete
Heres the Controller-Action:
function details()
{
$event_id = (int)Director::urlParam('ID');
$details = DataObject::get_by_id('Event', $event_id);
return $this
->customise(array('Eventdetails' => $details))
->renderWith(array('Tourdates_details', 'Page'));
}How do i fetch/join/merge the Data from both models ?
Any ideas would be great!
Robert
-
Re: Fetching (has_one) related Date

29 May 2009 at 4:23am
got it working:
function details()
{
$event_id = (int)Director::urlParam('ID');
$details = DataObject::get_by_id('Event', $event_id);
$location = $details->Eventlocation();
return $this
->customise(array('Eventdetails' => $details, 'Eventlocation'=>$location))
->renderWith(array('Tourdates_details', 'Page'));
}works.....
| 1067 Views | ||
|
Page:
1
|
Go to Top |

