I have extended the member class using dataobjectdecorator successfully, created custom login, registration and edit profile pages; however I am having a little trouble figuring out how I would create a view profile page.
I have created a viewprofile.php and viewprofile.ss page, setup similar to what exists in the forum module. Here is what I have in my viewprofile.php page.
<code>
class ViewProfile extends Page {
}
class ViewProfile_Controller extends Page_Controller {
function init() {
$member = $this->Member() ? $this->Member() : null;
$usernameText = ($member) ? ($member->Username . '\'s ') : '';
$this->Title = $usernameText . 'User Profile';
parent::init();
}
function Member() {
$member = null;
if(is_numeric($this->urlParams['ID'])) {
$member = DataObject::get_by_id('Member', $this->urlParams['ID']);
} else {
$member = Member::currentUser();
}
return $member;
}
} </code>
Here is what I have in my viewprofile.ss
<code>
<% control Member %>
<h1>$Username's <% _t('PROFILE','Profile') %></h1>
<p><b>Username: </b>$Username</p>
<% if FirstName %>
<p><b>First Name: </b>$FirstName</p>
<% end_if %>
<% if Surname %>
<p><b>Last Name: </b>$Surname</p>
<% end_if %>
<% if Website %>
<p><b>Website: </b>$Website</p>
<% end_if %>
<% end_control %></code>
At this point if I go to www.url.com/viewprofile/ when I am logged in it will show my profile. However I havent figured out how to display other users profiles by using urlParams. www.url.com/viewprofile/1 or any ID number doesnt return anything but a blank page. So it seems I am having a bit of trouble figuring out how to use urlParams to pass a member ID.
I have looked through the documentation but could use some more explanation of how urlParams work and how I can create a view profile page that will display any members profile by simply adding an ID number like this "www.url.com/viewprofile/1" where 1 is the member ID number.
Any help would be greatly appreciated.