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, biapar, Willr, Ingo, swaiba, simon_w

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


5 Posts   1266 Views


13 July 2010 at 1:23pm (Last edited: 14 July 2010 12:22pm), Community Member, 117 Posts

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?


13 July 2010 at 11:18pm Community Member, 78 Posts


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?



14 July 2010 at 3:22am Community Member, 117 Posts

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;


14 July 2010 at 12:21pm Community Member, 117 Posts

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


14 July 2010 at 1:02pm Community Member, 181 Posts

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.