2017 © Pedro Peláez
 

silverstripe-module silverstripe-member-profiles

SilverStripe extendable profile areas. Provides registration page and extendable profile page area.

image

a2nt/silverstripe-member-profiles

SilverStripe extendable profile areas. Provides registration page and extendable profile page area.

  • Wednesday, September 13, 2017
  • by a2nt
  • Repository
  • 1 Watchers
  • 3 Stars
  • 59 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

SilverStripe Profile Area Module

Maintainer Contact

Requirements

  • SilverStripe 3.2

Overview

A simplified light-weight alternative for frontend member profile areas., (*1)

  • Registration page
  • Profile page for updating details.
  • Extendable profile area

Registration Page

Create member Registration Page at the CMS or run /dev/build?flush after module instalation, (*2)

Member Profile Page

Create member Profile Page at the CMS or run /dev/build?flush after module instalation, (*3)

Profile Area

By default profile area has only profile information and profile editing form controller to add extra profile areas use this example:, (*4)

class MyProfileArea extends MemberProfilePage_Controller {
    /* ... your code
     * private static $allowed_actions = [
     *    'MyAction'
     * ];
     *
     * public function MyAction() {}
     *
    */
}

Profile information will use /profile URL, sub-controllers will use sub-URLs of this page for example: /profile/myprofilearea /profile/myprofilearea/action, (*5)

/profile/myprofileareaCRUD/MyItemClassName/new/ /profile/myprofileareaCRUD/MyItemClassName/view/11 /profile/myprofileareaCRUD/MyItemClassName/edit/11 /profile/myprofileareaCRUD/MyItemClassName/delete/11 /profile/myprofileareaCRUD/extraaction/ID/OtherID, (*6)

New area will be automatically added to frontend member profile area navigation menu, but you can add hide ancestor to keep it hidden:, (*7)

class MyProfileArea extends ProfileController {
    private static $hide_ancestor = false; // it's optional if you want to hide this controller set to true
    private static $menu_icon = '<i class="fa fa-pencil-square-o"></i>'; // optional icon
    private static $menu_title = 'My Profile Area'; // optional title otherwise My Profile Area title will be used
}

Requirements config example:, (*8)

ProfileController:
  requirements_css:
    - site/css/ProfileController.css
  requirements_javascript:
    - site/css/ProfileController.js

Profile CRUD

class MyProfileObjectsController extends ProfileCRUD {
    /*
     * This controller will let you create, view, edit and delete objects
     */
    private static $hide_ancestor = false; // it's optional if you want to hide this controller set to true
    private static $menu_icon = '<i class="fa fa-pencil-square-o"></i>'; // optional icon
    private static $menu_title = 'My Profile Area'; // optional title otherwise My Profile Area title will be used

    private static $managed_models = [
        'MyObject',
        'MyObject2',
    ];

    private static $allowed_actions = [
        'ExtraAction'
    ];

    public function ExtraAction() {}
}
  • to make "MyProfileArea" template create templates/profile/controllers/MyProfileArea.ss
  • it will be used as sub-template of MemberProfilePage.ss by using $ProfileArea variable just like $Layout requires sub-template of Page.ss, (*9)

  • to create a specific action template of "MyProfileArea" create templates/profile/controllers/MyProfileArea_MyAction.ss, (*10)

Use following code to customize MemberRegistrationForm:, (*11)

MemberRegistrationForm:
  extensions:
    - MyMemberRegistrationFormExtension
class MyMemberRegistrationFormExtension extends Extension
{
    public function updateMemberRegistrationForm()
    {
        /* your code, ex:
         * $fields = $this->owner->Fields();
         * $fields->push(TextField::create('MyField'));
         * BootstrapForm::apply_bootstrap_to_fieldlist($fields);
         * BootstrapForm::apply_bootstrap_to_fieldlist($this->owner->Actions());
        */
    }

    public function onRegister($member)
    {
        /* your code to execute on register for an instance extra notifications */
    }
}

Use following code to customize MemberEditProfileForm:, (*12)

MemberEditProfileForm:
  extensions:
    - MyMemberEditProfileFormExtension
class MyMemberEditProfileFormExtension extends Extension
{
    public function updateMemberEditProfileForm()
    {
        /* your code, ex:
         * $fields = $this->owner->Fields();
         * $fields->push(TextField::create('MyField'));
         * BootstrapForm::apply_bootstrap_to_fieldlist($fields);
         * BootstrapForm::apply_bootstrap_to_fieldlist($this->owner->Actions());
        */
    }
}

Use following code to extend Profile CRUD item forms:, (*13)

ProfileCRUD:
  extensions:
    - BootstrapItemEditForm
class BootstrapItemEditForm extends Extension
{
    public function permissionDenied()
    {
        // your code, for example:
        Page_Controller::setSiteMessage('You must log in to view your profile.', 'warning');
    }

    public function updateItemRemoved(DataObject $item)
    {
        // your code
    }

    public function updateItemRemoveDenied()
    {
        // your code
    }
    public function updateItemEditDenied()
    {
        // your code
    }

    public function updateItemEditSuccess(DataObject $item, array $data, $new = false)
    {
        if ($new) {
            $success_msg = 'New Item Created';
        } else {
            $success_msg = 'Item was updated';
        }

        // your code
    }

    public function updateItemForm($form)
    {
        $fields = $form->Fields();
        // setup bootstrap classes
        BootstrapForm::apply_bootstrap_to_fieldlist($fields);

        $fields = $form->Actions();
        // setup bootstrap classes
        BootstrapForm::apply_bootstrap_to_fieldlist($fields);
    }
}

My personal website, (*14)

Buy me a Beer, (*15)

The Versions

13/09 2017

dev-master

9999999-dev http://github.com/a2nt/silverstripe-member-profiles

SilverStripe extendable profile areas. Provides registration page and extendable profile page area.

  Sources   Download

BSD-3-Clause

The Requires

 

registration profile frontend silverstripe members

15/08 2017

dev-SS4

dev-SS4 http://github.com/a2nt/silverstripe-member-profiles

SilverStripe extendable profile areas. Provides registration page and extendable profile page area.

  Sources   Download

BSD-3-Clause

The Requires

 

registration profile frontend silverstripe members