21490 Posts in 5783 Topics by 2622 members
| Go to End | Next > | |
| Author | Topic: | 3413 Views |
-
How to hide a page type from CMS

21 April 2009 at 5:45am
I had asked this question long ago but never received any response and that thread is in the archives now so I am going to ask again and see if anything has changed in the new version of SS.
I am now using SS 2.3.1. I have created a new page type that extends Page and set the static $can_create = false;
I can still see this page type in the create new page dropdown and also in the dropdown that allows changing a pre-existing page to a new type.
I would like to be able to create the page and then never allow it to be created or selected anywhere again.
-
Re: How to hide a page type from CMS

21 April 2009 at 8:01pm
Hi micahsheets
From my experience, the $can_create variable doesn't do what it should. What worked for me was to override the canCreate method. Place something like this in your custom Page-Class:
public function canCreate(){
return false;
}It is also more versatile since you could make that return value dependent on the amount of pages created etc.
I don't know why there's such a thing as a canCreate method and a $can_create variable. Must be some sort of backwards-compatibility thing. -
Re: How to hide a page type from CMS

22 April 2009 at 1:32am
found an explanation to this in another thread: http://silverstripe.org/archive/show/51003?start=0#post51031
so, as simon_w mentions, $can_create is not applicable to admins -
Re: How to hide a page type from CMS

22 April 2009 at 3:59am
It would seem that the method proposed here by banal is the right one. I knew that the $can_create did not apply to admins so I created a limited user and logged in as that user but I could still see the page in the dropdowns.
-
Re: How to hide a page type from CMS

30 March 2010 at 2:48am Last edited: 30 March 2010 2:49am
Is it also posible to disable choice for RedriectPage and VirtualPage in the selectbox above the SiteTree?
-
Re: How to hide a page type from CMS

19 August 2010 at 2:40am
Yeah, I'd like to bump this one — the issue I'm having is that I want to hide a Page type that's part of a module, which I'd rather not edit if I can avoid it. I created a subclass of the module Page, which is what I'm using in the CMS, but I only want users to be able to create the subclass type and not the original. I tried using DataObjectDecorator:
// disable using regular calendar class in CMS
class Calendar_RemoveFromCMS extends DataObjectDecorator {
public function canCreate(){ return false; }
}DataObject::add_extension('Calendar', 'Calendar_RemoveFromCMS');
But it didn't work.
-
Re: How to hide a page type from CMS

11 March 2011 at 6:17am
Just found the weirdest way of removing, in my case, the VirtualPage from the AddPageOptions dropdown without having to hack core or use canCreate(). Just created an extremely superfluous pagetype, like this:
class NoVirtualPage extends VirtualPage implements HiddenClass {
static $hide_ancestor = 'VirtualPage';
}OK, this must definitely be the flu... But I thought I'd share (no, not the flu)
-
Re: How to hide a page type from CMS

19 March 2011 at 8:47am
Cool, i'll try this ty for sharing! so you created NoVirtualPage.php for this? Is this 'the' way to do this?
I also tried to disable items with jquery which was no succes.
| 3413 Views | ||
| Go to Top | Next > |





