I'm developing a Silverstripe module module allowing users to subscribe to a website which also sends out a monthly magazine.
There will be 2 levels of user in a single group. All users in this group will have be able to login to the site, but some content will only be visible to those with an active, paid subscription.
I have a DataExtension extending the main Page object. This allows me to have a boolean field to indicate subscriber only content. My intention was to add the "canView" function, which would perform the necessary checks on the user's subscription status to hide the links from inactive members, returning true for admin of course.
class MemberPageExtension extends DataExtension {
static $db = array(
'SubscribersOnly' => 'Boolean'
);
public function canView(){
// perform subscription checks here
return false ; // result will be dependent on subscription status
}
}
Unfortunately canView() doesn't seem to be working/available on a DataExtension, so now I'm a little stuck as to how to achieve this.
Is there a way to make the "can" functions available to a DataExtension on a Page, or produce a similar effect without the need for if statements in the templates?