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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

Extend Member or Decorate


Go to End


22 Posts   10127 Views

Avatar
Martin Pales

Community Member, 19 Posts

8 December 2010 at 10:24am

Avatar
DNA

Community Member, 24 Posts

8 December 2010 at 1:05pm

Hi,

I need to have multiple member types with distinct information associated with them. Have been reading about decorating the member. However as each decorator affects all the base table it seems a little inelegant.

So thought this approach might work and am looking for feedback.

1) Decorate Member with MyMember which has_one MemberExtend
2) Create MemberExtend which extends DataObject
3) Subclass MemberExtend which each type I need.

Then each member has 1 set of associated info at the MemberExtend Object. The MemberExtend object in infinitely subclassable (clearly not a word).

The only downsides I see are:
1) Backend isn't aware of extra data
2) MemberExtend could potentially have multiple Members (this relationship could be turned around, but the same thing occurs)

Thoughts? Maybe I'm over thinking this.

Avatar
DNA

Community Member, 24 Posts

8 December 2010 at 2:16pm

Actually upon reflection, if you turn the relationship around. MyMember has many MemberExtends. Then you can have a member with multiple usertypes.

Which is kinda sweet and fixes Sminnee's issue here: http://groups.google.com/group/silverstripe-dev/browse_thread/thread/4519e2b9b5e967db/79b0aa3075d67d18?lnk=gst

Avatar
DNA

Community Member, 24 Posts

8 December 2010 at 2:55pm

A better name for MemberExtend is probably Role.

Avatar
Ingo

Forum Moderator, 801 Posts

15 December 2010 at 9:50pm

There's even a brief digression on this topic in the docs :) http://doc.silverstripe.org/member

Avatar
micahsheets

Community Member, 165 Posts

6 January 2011 at 11:21am

The problem with decorating Member is that all members get the added stuff. In many cases the need for a special Member is that a site needs a way for people to log into the website and not the CMS. If I need to store information for members that are website only then I subclass Member so that administration users don't get a bunch of info that is not relevant to them. I also usually create a custom loginForm so that when the special member logs in they get sent to the page they should see. I use ModelAdmin to administrate my special members. In fact I have never found a reason to decorate the built in Member class as the current one does most everything needed for CMS administration.

Go to Top