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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

canCreate and Drag-and-Drop

Go to End

4 Posts   1099 Views


Community Member, 165 Posts

20 March 2014 at 11:25am

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.


Community Member, 165 Posts

20 March 2014 at 11:55am

I found this on github

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


Community Member, 607 Posts

21 March 2014 at 5:10pm

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.


Community Member, 165 Posts

21 March 2014 at 11:00pm

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