Kavinda Harshana
Kavinda Harshana

Reputation: 117

how display another object of data in a Templates

this is Area class function

        public function findLatestReport()
    {
        $getReport = Report::get()->filter('AreaID',$this->ID)
            ->sort('Date ASC')->first();
        return $getReport;
    }

This is Report class function

    public function getWeatherStatus()
    {
        return $this->Fields()->filter('Name', 'Weather Status')->first();
    }

is there any way to display 'area' template of WeatherStatus details.??

<% loop $findLatestReport %>
        {$WeatherStatus}
<% end_loop %>

Upvotes: 1

Views: 42

Answers (1)

Cheddam
Cheddam

Reputation: 161

You'll need to use with, rather than loop, as you're returning a single DataObject (with ->first()) rather than a list. Then you should be able to access $WeatherStatus:

<% with $findLatestReport %>
    {$WeatherStatus}
<% end_with %>

Upvotes: 5

Related Questions