Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » canCreate and Drag-and-Drop

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

Page: 1
Go to End
Author Topic: 372 Views
  • _Vince
    Avatar
    Community Member
    161 Posts

    canCreate and Drag-and-Drop Link to this post

    Hi, all.

    I have some custom page types, and I only want ONE page of these types to be created.

    So I add the following:

    /**********************************************************************/
       public function canCreate($member = null) {
    /**********************************************************************/
          return !DataObject::get_one($this->ClassName);
       }

    and it works well.

    BUT... the CMS doesn't let me rearrange the pages. I can't drag and drop them along the site tree.

    How can I limit the number of pages?

    I've thought of doing something with onBeforeWrite() but that doesn't remove the custom pages from the list of possible page types.

  • _Vince
    Avatar
    Community Member
    161 Posts

    Re: canCreate and Drag-and-Drop Link to this post

    I found this on github

    https://github.com/silverstripe/silverstripe-cms/issues/657

    which describes the problem perfectly. Unfortunately, I don't understand the "use canEdit()" part. Can someone post an example?

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: canCreate and Drag-and-Drop Link to this post

    I think they posters in that discussion mean that they want to check the canEdit permission in /cms/code/controllers/CMSMain.php SiteTreeHints() (so part of Silverstripe's CMS core).

    It seems that the code that handles this is checking canCreate, but not canEdit. So these devs are talking that doing so would resolve the situation.

    It also seems that no one has touched this one for quite some time. You could comment on Github to see if there's an update. They were talking about doing it another way, so someone there may know more.

  • _Vince
    Avatar
    Community Member
    161 Posts

    Re: canCreate and Drag-and-Drop Link to this post

    Cheers, thanks. That's what I thought they meant.

    372 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.