You could have a dataobject 'Teacher' and a 'ManageTeachers' page. Say you have a ManageTeachers.php page and on the site you give it the url http://mysite.com/teachers/
You could have a method in the ManageTeachers page called edit() and one called view(). What both these methods would do (see the forum module for how it does this as an example) is you could pass the ID of the teacher page then based on the action (edit or view) display a form or the data. (Im going to cut out alot of the nice stuff for the sake of writing this)
// in ManageTeachers.php
class ManageTeacher_Controller extends Page_Controller {
function view() {
// check to see if the URL structure is correct
if(isset(Director::urlParams('ID')) && is_numeric(Director::urlParams('ID')) {
// it is so try and get the teachers Info
$teacher = DataObject::get_by_id("Teacher", Director::urlParams('ID'));
}
return array(
"Teacher" => $teacher
);
}
Now you can call that method in the URL by going
http://mysite.com/teachers/view/102 - which will get the teacher with ID 102. You can now access that teachers data in the template by going <% Control Teacher %> or $Teacher.Name
Now the edit ones a bit more tricky as you are going to have to construct the form etc so what you would have is under that view method
function edit() {
// check to see if the URL structure is correct
if(isset(Director::urlParams('ID')) && is_numeric(Director::urlParams('ID')) {
// it is so try and get the teachers Info
$teacher = DataObject::get_by_id("Teacher", Director::urlParams('ID'));
}
// CHECK PERMISSIONS - admin & user should only be able to edit this.
// LEFT THIS OUT.
$fields = new FieldSet(
// define the fields you want to edit on your teacher object
);
$actions = // whatever actions
$form = new Form($this, $fields, $actions);
$form->loadData($teacher);
return array(
"Form" => $form
);
}
So basically the edit method is a bit harder as you will need to construct forms and call loadData on the teacher object - which will load all the data from the Teacher into the form. And you also need to complete the permissions bit to check for correct user etc.