Hi!
I'm trying to set up a page modifying the example in tutorial 5, but now I got stuck... I'd really appreciate if someone could help me out...
So, I extended the data object like this:
class Teacher extends DataObject {
static $db = array(
'FirstName' => 'Text',
'LastName' => 'Text',
'Email' => 'Text',
'PersonalInfo' => 'Text'
);
static $has_one = array(
'MyTeacher' => 'TeacherPage',
'Photo' => 'Image'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField('FirstName', 'Vorname'));
$fields->push( new TextField('LastName', 'Nachname'));
$fields->push( new TextField('Email', 'Email'));
$fields->push( new TextAreaField('PersonalInfo', 'Persönliche Informationen'));
return $fields;
}
}
Then I created a page in order to contain all this information:
class TeacherPage extends Page {
static $db = array();
static $has_many = array(
'MyTeachers' => 'Teacher'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$tablefield = new HasManyComplexTableField(
$this,
'MyTeachers',
'Teacher',
array( 'FirstName' => 'Vorname',
'LastName' => 'Nachname',
'Email' => 'Email',
'PersonalInfo' => 'Persönliche Infos'),
'getCMSFields_forPopup'
);
$tablefield->setAddTitle( 'Lehrer' );
$fields->addFieldToTab( 'Root.Content.Lehrer', $tablefield);
return $fields;
}
}
The cms looks just fine and I can add all the information that I want. But when I'm trying to display all this information, I run into troubles... I don't know how to access the data, correctly... I thought it was supposed to look like this.
<div id="TeachersList">
<% if MyTeachers %>
<% control MyTeachers %>
<div class="TeacherInfo">
<h3>$FirstName $LastName</h3>
</div>
<% end_control %>
<% else %>
nothing found
<% end_if %>
</div>