Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Add Fields: Member Profiles Module SS3


Go to End
Reply


9 Posts   612 Views

Avatar
Pix

Community Member, 153 Posts

18 January 2013 at 7:49am

Can anyone tell me how to do something as simple as adding some fields (like address, telephone) to the Member Profile Pages Module for SS3? I've found tons of tutorials that don't seem to work anymore since none of them apply to SS3 version of the module :0(

Thank you.

Avatar
Johnny9

Community Member, 22 Posts

9 September 2013 at 10:22am

Hi Pix, maybe you figured out how to add extra fields to member profile module? :)

Avatar
Till

Community Member, 3 Posts

24 September 2014 at 5:26am

I've also spent a couple of hours on trying to add custom fields and I don't want to learn all of SS from scratch. It would be so helpful to add a few lines to the instructions on the readme file to make it clear.
I would be extremely grateful if someone could answer these two questions:
1.) "hooking into

`Member::updateMemberFormFields`

to add the form field" - To which file in which directory do I add this?
2.)

```php
class MemberExtension extends DataExtension {

private static $db = array(
'PhoneNumber' => 'Text'
);

public function updateMemberFormFields(FieldList $fields) {
$fields->push(new TextField('PhoneNumber', 'Phone number'));
}
}

- Do I save this to a specific file name and to which directory?

Avatar
Till

Community Member, 3 Posts

26 September 2014 at 5:17pm

Solved it, but I'd wish that more SS instructions were written to be used without going into ever more details. SS is great, but other cms make it easier for the beginner to extend and change.

Avatar
darkan

Community Member, 2 Posts

3 October 2014 at 11:00pm

Hello. I'm exactly with de same pb...
"Solved it, but I'd wish that more SS instructions were written to be used... "
Please can you me/us more ?
I just have lost all my hair... ;-)
Thanks

Avatar
Till

Community Member, 3 Posts

5 October 2014 at 5:08am

Edited: 05/10/2014 5:13am

Find and open the config.yml file here
\mysite\_config\config.yml
add this:

# My new member formfields
Member:
extensions:
- MyMemberExtension


(only use spaces for indents - no tabs)
Next
make a new file in the \mysite\code\ directory called MyMemberExtension.php

This is my example of the file "MyMemberExtension.php" with the fields that I added. Just modify according to your needs and now the fields will show up on your memberprofile page inside the admin section of SS.

<?php
// mysite/code/MyMemberExtension.php
class MyMemberExtension extends DataExtension {

private static $db = array(
'CURDEBT' => 'Varchar(8)',
   'username' => 'Varchar(60)',
// 'geburtstag' => 'Date',
   'geburtstag' => 'Varchar(20)',
   'elt_email' => 'Varchar(100)',
   'CARD' => 'Varchar(11)',
   'TAXID' => 'Varchar(11)',
   'kerngruppe' => 'Varchar(5)',
'PHONE' => 'Varchar(50)',
'PHONE2' => 'Varchar(50)',
   'elt_vorname' => 'Varchar(50)',
   'elt_nachname' => 'Varchar(60)',
   'ADDRESS' => 'Varchar(100)',
   'POSTAL' => 'Varchar(5)',
   'NAME' => 'Varchar(50)',
   'MAXDEBT' => 'Varchar(8)',
   'NOTES' => 'Varchar(150)',
   'Karte' => 'Date',
   'dateiname' => 'Varchar(30)'
);

public function updateMemberFormFields(FieldList $fields) {
$fields->push(new TextField('CURDEBT', 'Guthaben erscheint als Minusbetrag'));
$fields->push(new TextField('username', 'Benutzername'));
$fields->push(new TextField('geburtstag', 'Geburtsdatum'));
$fields->push(new TextField('elt_email', 'Eltern E-Mail'));
$fields->push(new TextField('CARD', 'Kartennummer'));
$fields->push(new TextField('TAXID', 'TAXID'));
$fields->push(new TextField('kerngruppe', 'Kerngruppe'));
$fields->push(new TextField('PHONE', 'Mobil-Telefon Nummer'));
$fields->push(new TextField('PHONE2', 'Festnetz Telefon'));
$fields->push(new TextField('elt_vorname', 'Eltern Vorname'));
$fields->push(new TextField('elt_nachname', 'Eltern Nachname'));
$fields->push(new TextField('ADDRESS', 'Anschrift'));
$fields->push(new TextField('POSTAL', 'Postleitzahl'));
$fields->push(new TextField('NAME', 'Unicenta Name'));
$fields->push(new TextField('MAXDEBT', 'Schueler Kredit'));
$fields->push(new TextField('NOTES', 'Notizen'));
$fields->push(new TextField('Karte', 'Karte ausgestellt'));
$fields->push(new TextField('dateiname', 'Dateiname'));

}

static $has_one = array(
'Image' => 'Image'
);
public function getCMSFields() {
$this->extend('updateCMSFields', $fields);
return $fields;
}
public function updateCMSFields(FieldList $fields) {
$fields->push($imageUpload = new UploadField('Image', 'Mein Foto'));

$imageUpload->setFolderName('Profile');

return $fields;
}

}

Avatar
darkan

Community Member, 2 Posts

5 October 2014 at 9:54pm

Hello,
Thanks a lot for you're answer. You're a real Doctor for my head and my hair :-)

I just change change the directory location.

My "memberprofiles" module is in my /www/ directory.
So i created the php file in "/www/memberprofiles/code/MyMemberExtension.php"

And i've add in the "/www/memberprofiles/_config/extension.yml":
---
Name: extensions
---
Member:
extensions:
['MemberProfileExtension']
extensions:
['MyMemberExtension']

And now, all is right !
Thanks for you're Help.
Sorry for by bad english... ;-)

Avatar
Bruce B

Community Member, 147 Posts

15 October 2014 at 2:14pm

Thank you Till! Thank you Darkan!
Very clear, exact instructions so I can stop hitting my head against the wall. I would have liked Till's version to work (and feel that it should) but I'm happy that Darkan posted an alternate that worked immediately.
My one small contribution: If you are trying Till's version, you need exactly one space before 'extensions:' and '- MyMemberExtension'. These yml files seem to be very fussy.

cheers
bruce

Go to Top