I can't get nested controls working. Am I doing something wrong?
In the example below, the datasets are static (to simplify the code). In real life, they are nested results of database queries.
When the two datasets are shown on their own, they work, but when they are nested inside each other, the inner control doesn't work. (See results at the end)
NestedControls.php
<?php
class NestedControls extends Page {
static $db = array( );
public function Rows() {
$Columns = array();
$Columns[] = array( 'Content' => 'Row1' );
$Columns[] = array( 'Content' => 'Row2' );
$Columns[] = array( 'Content' => 'Row3' );
return new DataObjectSet($Columns);
}
public function Columns() {
$Columns = array();
$Columns[] = array( 'Content' => 'Col1' );
$Columns[] = array( 'Content' => 'Col2' );
$Columns[] = array( 'Content' => 'Col3' );
return new DataObjectSet($Columns);
}
}
class NestedControls_Controller extends Page_Controller {
public function init() {
parent::init();
}
}
?>
NestedControls.ss
<h1>Rows on their own</h1>
<% control Rows %>
This is $Pos of $TotalItems: $Content<br/>
<% end_control %>
<h1>Columns on their own</h1>
<% control Columns %>
This is $Pos of $TotalItems: $Content<br/>
<% end_control %>
<h1>Columns inside rows</h1>
<% control Rows %>
This is $Pos of $TotalItems: $Content<br/>
<% control Columns %>
This is $Pos of $TotalItems: $Content<br/>
<% end_control %>
<% end_control %>
<h1>Rows inside columns</h1>
<% control Columns %>
This is $Pos of $TotalItems: $Content<br/>
<% control Rows %>
This is $Pos of $TotalItems: $Content<br/>
<% end_control %>
<% end_control %>
Results
Rows on their own
This is 1 of 3: Row1
This is 2 of 3: Row2
This is 3 of 3: Row3
Columns on their own
This is 1 of 3: Col1
This is 2 of 3: Col2
This is 3 of 3: Col3
Columns inside rows
This is 1 of 3: Row1
This is 1 of :
This is 2 of 3: Row2
This is 1 of :
This is 3 of 3: Row3
This is 1 of :
Rows inside columns
This is 1 of 3: Col1
This is 1 of :
This is 2 of 3: Col2
This is 1 of :
This is 3 of 3: Col3
This is 1 of :