I'm sure I've been here before, but can't find any old posts.
I have the following structure for a global ski resort website that I have inherited:
1. A CountryPage
2. A ResortPage (A child of CountryPage)
3. A HotelPage (A child of ResortPage)
Although these are related to each other in the site tree as actual pages, the information on the last one, HotelPage, is actually displayed one after the other on the ResortPage.
So a simplified setup of ResortPage.ss is as follows:
<!-- Resort Info -->
$Name
$Content
<!-- Hotels in this Resort -->
<% control Children %>
$Name
$Content
$GetPricing
<% end_control %>
This is all working well except for the "GetPricing". This is a function on HotelPage.php that returns a HTML table using data from an element on the HotelPage called "Pricing". This is a TableField, which in turn is an extension of DataObject.
This is the code in HotelPage.php
function GetPricing() {
$submitLink = DataObject::get("Pricing", "ThispriceID = $this->ID");
$output = $this->makeTable($submitLink);
return $submitLink;
}
private function makeTable($PricingData) {
// Code for intelligently creating table based on $PricingData
{
This works perfectly if I look at the HotelPage directly, but the function isn't called when I'm trying to list these pages on the ResortPage using <% control Children %>. So I must have a scope problem.
Can anyone see a way around this?
Cheers
Aaron