I'm sure this is a simple question for the PHP/SS experts out there, but I'm stuck. I've worked through the dataobject tutorial, but all I really need is to display a simple table. In this case, it's a list of musical selections, so the headings are 'composer,' 'title,' and 'role.'
I set everything up as specified at the beginning of the tutorial, but I can only get ONE entry (row, whatever you want to call it) to display. I don't know whether this is because of the has_one relation or not.
I created a page (modeled after the "Project" page) called Opera. I changed "Students" (in the tutorial) to Repertoire, and added a few entries. But I can only get a single line of composer/title/role to display:
Composer | Title | Role
Bellini La Donna Alfredo
...when I really have several entries I need displayed!
---------------
Here's my code RepProject.php:
<?php
/**
* Defines the RepProject page type
*/
class RepProject extends Page {
static $has_one = array(
'MyRep' => 'Rep'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$tablefield = new HasOneComplexTableField(
$this,
'MyRep',
'Rep',
array(
'Composer' => 'Composer',
'Title' => 'Title',
'Role' => 'Role'
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab( 'Root.Content.Rep', $tablefield );
return $fields;
}
}
class Project_Controller extends Page_Controller {
}
?>
-----------------------------
and the SS template:
<div id="Content" class="typography">
<h2>$Title</h2>
$Content
<h3>Repertoire</h3>
<table id="Rep">
<thead>
<tr>
<th>Composer</th>
<th>Title</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<% control MyRep %>
<tr>
<td><p><strong>$Composer</strong></p></td>
<td><p><strong>$Title</strong></p></td>
<td><p><strong>$Role</strong></p></td>
</tr>
<% end_control %>
</tbody></table>
$Form
$PageComments
</div>
-----------------------
Sorry to sound like a Php/MySQL retard, but I've struggled with this for hours - and now I'm finally appealing for help. My relationships are much simpler than what's in the tutorial... I just need to know how to spit out the whole table! Thank you so much, any help is appreciated.