21489 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1027 Views |
-
[Solved] How do I hide page type from a module?

13 July 2010 at 1:23pm Last edited: 14 July 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:
http://www.silverstripe.org/general-questions/show/258913?start=0
http://silverstripe.org/archive/show/51003?start=0#post51031but 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?
-
Re: [Solved] How do I hide page type from a module?

13 July 2010 at 11:18pm
Hi.
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?
Mark
-
Re: [Solved] How do I hide page type from a module?

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;
-
Re: [Solved] How do I hide page type from a module?

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';
-
Re: [Solved] How do I hide page type from a module?

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.
| 1027 Views | ||
|
Page:
1
|
Go to Top |


