Skip to content

Commit

Permalink
Streamline account templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewis-everley committed Feb 22, 2018
1 parent debec2f commit b7577ba
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 63 deletions.
37 changes: 29 additions & 8 deletions code/control/Users_Account_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,33 @@ public function RelativeLink($action = null)
*/
public function index()
{
// Setup default profile summary sections
$sections = ArrayList::create();

$sections->push(ArrayData::create(array(
"Title" => "",
"Content" => $this->renderWith(
"UsersProfileSummary",
array("CurrentUser" => Member::currentUser())
)
)));

// Allow users to add extra content sections to the
// summary
$this->extend("updateContentSections", $sections);

$this->customise(array(
"ClassName" => "AccountPage"
"Title" => _t('Users.ProfileSummary', 'Profile Summary'),
"MetaTitle" => _t('Users.ProfileSummary', 'Profile Summary'),
"Content" => $this->renderWith(
"UsersAccountSections",
array("Sections" => $sections)
)
));

$this->extend("onBeforeIndex");

return $this->renderWith(array(
"UserAccount",
"UserAccount",
"Page"
));
Expand All @@ -162,7 +181,8 @@ public function edit()
}

$this->customise(array(
"ClassName" => "AccountPage",
"Title" => _t("Users.EditAccountDetails", "Edit account details"),
"MetaTitle" => _t("Users.EditAccountDetails", "Edit account details"),
"Form" => $form
));

Expand Down Expand Up @@ -197,7 +217,8 @@ public function changepassword()
}

$this->customise(array(
"ClassName" => "AccountPage",
"Title" => _t("Security.ChangeYourPassword", "Change your password"),
"MetaTitle" => _t("Security.ChangeYourPassword", "Change your password"),
"Form" => $form
));

Expand Down Expand Up @@ -263,25 +284,25 @@ public function ChangePasswordForm()
*/
public function getAccountMenu()
{
$menu = new ArrayList();
$menu = ArrayList::create();

$curr_action = $this->request->param("Action");

$menu->add(new ArrayData(array(
$menu->add(ArrayData::create(array(
"ID" => 0,
"Title" => _t('Users.PROFILESUMMARY', "Profile Summary"),
"Link" => $this->Link(),
"LinkingMode" => (!$curr_action) ? "current" : "link"
)));

$menu->add(new ArrayData(array(
$menu->add(ArrayData::create(array(
"ID" => 10,
"Title" => _t('Users.EDITDETAILS', "Edit account details"),
"Link" => $this->Link("edit"),
"LinkingMode" => ($curr_action == "edit") ? "current" : "link"
)));

$menu->add(new ArrayData(array(
$menu->add(ArrayData::create(array(
"ID" => 30,
"Title" => _t('Users.CHANGEPASSWORD', "Change password"),
"Link" => $this->Link("changepassword"),
Expand Down
5 changes: 5 additions & 0 deletions templates/Includes/UsersAccountSections.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% loop $Sections %>
<h2>$Title</h2>

<div class="section-content">$Content</div>
<% end_loop %>
9 changes: 9 additions & 0 deletions templates/Includes/UsersProfileSummary.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% with $CurrentUser %>
<div class="users-profile-summary">
<p>
<strong><% _t('Member.FIRSTNAME',"First Name") %></strong> $FirstName<br/>
<strong><% _t('Member.SURNAME',"Surname") %></strong> $Surname<br/>
<strong><% _t("Member.EMAIL","Email") %></strong> $Email<br/>
</p>
</div>
<% end_with %>
13 changes: 2 additions & 11 deletions templates/Layout/UserAccount.ss
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,9 @@
</div>
<% end_if %>

<h1><%t Users.ProfileSummary "Profile Summary" %></h1>

<% with $CurrentUser %>
<div class="users-profile-summary">
<p>
<strong><% _t('Member.FIRSTNAME',"First Name") %></strong> $FirstName<br/>
<strong><% _t('Member.SURNAME',"Surname") %></strong> $Surname<br/>
<strong><% _t("Member.EMAIL","Email") %></strong> $Email<br/>
</p>
</div>
<% end_with %>
<h1>$Title</h1>

<div class="content">$Content</div>

$Form
</div>
Expand Down
22 changes: 0 additions & 22 deletions templates/Layout/UserAccount_changepassword.ss

This file was deleted.

22 changes: 0 additions & 22 deletions templates/Layout/UserAccount_edit.ss

This file was deleted.

0 comments on commit b7577ba

Please sign in to comment.