Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » restrict creation of album

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 811 Views
  • Rishi
    Avatar
    Community Member
    97 Posts

    restrict creation of album Link to this post

    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

  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Re: restrict creation of album Link to this post

    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;
    }
    }

  • UncleCheese
    Avatar
    4085 Posts

    Re: restrict creation of album Link to this post

    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";

  • Rishi
    Avatar
    Community Member
    97 Posts

    Re: restrict creation of album Link to this post

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

    811 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.