17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1746 Views |
-
DataObject::get_by_id() returns error

15 June 2008 at 7:25pm Last edited: 15 June 2008 7:26pm
Hi (again). I have added a dropdown box to my page type "Tour". This Dropdown box contains the site tree. The purpose of it is to link one Tour to another (beacuse the tours are offered in reverse itineraries). This works well, and saves the value of the select Reverse Tour in a field called ReversTourID.
Now I am trying to access this reverse tour and add a link in the template to that page. I have found other threads on this and have added a function to Tour.php (which extends Page)function GetReverseTour() {
$thisPage = DataObject::get_by_id("Page",$this->ReverseTourID);
return $thisPage;
}
I have also tried replacing "Page" with "Tour", but in debug mode, I get this error when I call the above function:FATAL ERROR: Object::__call() Method 'forTemplate' not found in class 'Tour'
Any Ideas? Am I out of the DataObject scope here? Isn't page a decendant of SiteTree, and thus DataObject?
Cheers
Aaron -
Re: DataObject::get_by_id() returns error

15 June 2008 at 7:32pm
Dammit, I figured it out (again).
It was returning an entire page object. I had to call the function like so:GetReverseTour.Link
If I wanted the link that is. I guess the existing page simply didn't know what to do with the data that was returned.
Cheers
Aaron
| 1746 Views | ||
|
Page:
1
|
Go to Top |

