17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1826 Views |
-
Hiding a class from 'Create' menu.

20 July 2007 at 10:47am Last edited: 20 July 2007 2:47pm
Hi,
I have a parent class 'Product' and a child classes like 'Hotel', 'Activity', etc. I do not want users to create a page of type 'Product'. I have looked into to SS code, so the relevant methods are:CMSMain::PageTypes()
SiteTree:getClassDropdown()I see I can hide the class Product if it implements the 'HiddenClass' interface. But then all subclasses would be hidden as well.
There's a weird piece of code in CMSMain::PageTypes(). If the child class has a static variable $hide_ancestor which is equal to the order (number) of a class in the array, which is returned by ClassInfo::getValidSubClasses(), then this class is hidden. And this piece of the code is not implemented in the SiteTree:getClassDropdown().
CMSMain::PageTypes() also check, if the method canCreate(). Which is suitable solution for me, but this is not implemented in SiteTree:getClassDropdown(), unfortunatelly. This is also a mild security issue. If the permission canCreate fails for the current user, he/she can still create a page of another type and then change the type of the page.
So, I've made the followin change:
--- SiteTree.php.orig 2007-07-05 17:20:39.000000000 +1200
+++ SiteTree.php 2007-07-20 11:28:42.000000000 +1200
@@ -694,7 +694,8 @@
array_shift($classes);
foreach($classes as $class) {
$instance = singleton($class);
- if(($instance instanceof HiddenClass) && ($class != $this->class)) continue;
+ if ((($instance instanceof HiddenClass) || !$instance->canCreate()) &&
+ ($class != $this->class)) continue;$addAction = $instance->uninherited('add_action', true);
if(!$addAction) $addAction = "a $class";However, this does not prevent the user to duplicate the forbidden page
-
Re: Hiding a class from 'Create' menu.

17 September 2008 at 7:06pm
Hi,
I'm having difficulty with the 'create' menu. I have say 10 templates, including 'NewsHolderPage' and 'NewsPage'. Now if I have my 'NewsHolderPage' page selected in the sitemap of the cms and want to create a new page then I only want 'NewsPage' to be available. Is this possible?
Currently the user gets presented with every template whenever they create a page which is not ideal.
Matt
| 1826 Views | ||
|
Page:
1
|
Go to Top |


