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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[Solved] How do I hide page type from a module?

Go to End

5 Posts   2140 Views


Community Member, 117 Posts

13 July 2010 at 1:23pm

Edited: 14/07/2010 12:22pm

I'm made a slight extension to ImageGalleryPage, so my new page type is MyImageGalleryPage. What i need to do now is ensure that even Admin user on a website is not given option to create a page using the original page type.

Now I've found both these threads:

but both suggest making change to the page you 3wish to disable, in my case ImageGalleryPage.php

Now my problem is that if I do that then this change will be negated every time I upgrade the ImageGallery module.

Can I disable ImageGalleryPage from within MyImageGalleryPage.php?


Community Member, 78 Posts

13 July 2010 at 11:18pm


When you subclass a Page (or derivative of SiteTree, more specifically), and you don't want people creating instances of the base class, you can define in the subclass:

static $hide_ancestor = true;

So you would put that in MyImageGalleryPage to prevent ImageGalleryPage from showing as a create option.

Is that the behaviour you're after?



Community Member, 117 Posts

14 July 2010 at 3:22am

Thanks for reply Mark.

Yes that's what I want to achieve but your suggestion is not working... i.e. ImageGalleryPage still appears in page type drop-down.

Presumably at the start of class definition is fine?

class MyImageGalleryPage extends ImageGalleryPage

	static $hide_ancestor = true; 


Community Member, 117 Posts

14 July 2010 at 12:21pm

Ok the correct usage seems to be to specify the name of the parent page type you wish to hide i.e.

static $hide_ancestor = 'ImageGalleryPage';


Community Member, 181 Posts

14 July 2010 at 1:02pm

Yeah, it is a little confusing but as an interesting side effect, you can hide any page type from the drop-down, if you didn't want to create a decorator, simply by putting it's class in there - in your Page class for example:

static $hide_ancestor = "ErrorPage";

would remove the error page from the drop down.