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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

restrict creation of album


Go to End


4 Posts   1499 Views

Avatar
Rishi

Community Member, 97 Posts

16 March 2010 at 10:15pm

I have extended album page and its working fine .
i want to restrict the creation of album in admin panel
it means i want to have only one album(default album),so that admin cannot create any other album

thank you in advance

Avatar
bartvanirsel

Community Member, 96 Posts

16 March 2010 at 10:34pm

Hi Rishi,

I think this can be done by using the canCreate method in your AlbumPage class.

function canCreate() {
      if(DataObject::get_one('AlbumPage')) {
         return false;
      } else {
         return true;
      }
   }

Avatar
UncleCheese

Forum Moderator, 4102 Posts

17 March 2010 at 2:41am

Yeah, create a subclass of ImageGalleryAlbum, and create a function like:

public function canCreate() {
return !DataObject::get_one(__CLASS__);
}

Then create a subclass of ImageGalleryPage, and assign the new album class

protected $albumClass = "MyAlbumSubclass";

Avatar
Rishi

Community Member, 97 Posts

17 March 2010 at 5:35pm

thank you UC and bartvanirsel
that solve my problem.thanks a lot