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.

Data Model Questions

Extend Member or Decorate


Reply

22 Posts   5656 Views

Avatar
Martin Pales

8 December 2010 at 10:24am Community Member, 19 Posts

Another good explanation here:
http://silverstripe.org/customising-the-cms/show/11027#post278622

Cheers.

Avatar
DNA

8 December 2010 at 1:05pm Community Member, 24 Posts

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

8 December 2010 at 2:16pm Community Member, 24 Posts

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

8 December 2010 at 2:55pm Community Member, 24 Posts

A better name for MemberExtend is probably Role.

Avatar
Ingo

15 December 2010 at 9:50pm Forum Moderator, 801 Posts

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

Avatar
micahsheets

6 January 2011 at 11:21am Community Member, 164 Posts

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.