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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Newbie advice, please...


Go to End


3 Posts   923 Views

Avatar
captain grimes

Community Member, 1 Post

22 June 2010 at 10:28am

Hi all - this is a very basic question indeed and I hope that someone can give me a steer on this. I need to put together a content managed site for a client and thought that SilverStripe might be a solution that would meet their requirements.
What I'm not clear about is whether the specific piece of functionality that I need to offer the client can be met through SS, so I'm hoping that if someone's been down a similar route already they can give me a yes or no?
The site will be for a pre-school group and among other things, the client wants to be able to upload material that is specific to each child and which can only be seen by the child's parents via a secure login. OK, I could spend some time putting this together in PHP/MySQL and set up a whole bunch of logins for different kids/parents, but I wondered if there was either this functionality built-in to SS that I can use straight out of the box, or an extension that could be uploaded that would help. From what I've seen I'm guessing that one way of doing this would be to set up each person as a separate user group with access only to a specific page or pages, but perhaps that's not the best/easiest way of doing this?
I hope I've explained what I'm looking for here and that someone can point me in the right direction. Thanks in advance for any assistance/guidance.

Avatar
Carbon Crayon

Community Member, 598 Posts

22 June 2010 at 11:09am

Edited: 22/06/2010 11:11am

Hi Capain Grimes,

This sort of functionality is perfectly possible with SilverStripe, however it does require a certain amount of customization. SS will take care of all the authentication etc. but you will need to create the classes/db fields for your specific implementation.

Here is a brief outline of how it might be done:

1. Create a dataobject to hold each file and any accociated data.
2. Decorate or extend Member class to have a has_many or many_many relationship to the above DataObject. This allows you to attach multiple files to an individual member. In this case it is probably best to extend member so that you can manage them in ModelAdmin. There is infact a great example of this functionality in the SilverStripe book.
3. Create a member 'Account' page type which will allow members to login and view the files which are accociated with them. This would be done by creating a function in your controller to return the current members files, something like this:


function getMembersFiles(){

if($Member = Member::currentMember()){

return $Member->FileObjects(); //Where FileObjects is the name of ur Relationship

}

}

then in the CMS set that page to be only viewable by logged in users, or if you want more control do something like this in the template:


<% if CurrentUser %>

<% control MemberFiles %>
$Something
<% end_if %>

<% else %>
<p>Sorry you must be logged in to view this page, bla bla bla I can write what I want</p>
<% end_if %

Anyway I know that's not exactly a copy and paste solution, but hopefully it will give you enough info to get started :) Believe me, SilverStripe flexible enough to do almost anything with and it will continue to surprise you at how easily it lets you do it!

Aram

www.SSBits.com - SilverStripe Tutorials, Tips and other bits.

Avatar
bummzack

Community Member, 904 Posts

22 June 2010 at 8:08pm

You could also download and install the Secure Files Module (http://silverstripe.org/secure-files/).
I think it does exactly what you need?