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.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

hide_ancestor not working


Reply

4 Posts   1614 Views

Avatar
freeyland

3 August 2007 at 9:54pm (Last edited: 3 August 2007 11:09pm), Community Member, 22 Posts

I am trying to hide the ancestor class, but in the sitetree the pagetype 'Productgroup' is still available. Anyone has an idea why?

class ProductGroupRandom extends ProductGroup {
   static $hide_ancestor = ProductGroup;
   
   
}

class ProductGroupRandom_Controller extends ProductGroup_Controller {
   public function Testfuntion($showAll = false) {
         $hallo="test";
         return $hallo;
      
   }   
      
}

Avatar
Sean

4 August 2007 at 4:49pm (Last edited: 4 August 2007 4:53pm), Forum Moderator, 921 Posts

There's some more reference for this that can be found here:

[url]http://www.silverstripe.com/general-discussion/flat/2741[/url]

It's possible that the fix was implemented into the development branch of SilverStripe, so perhaps the code change on that forum post will help.

Cheers,
Sean

Avatar
Sean

4 August 2007 at 4:51pm (Last edited: 4 August 2007 4:53pm), Forum Moderator, 921 Posts

You might also want to try putting $hide_ancestor = 'ProductGroup'; rather than just ProductGroup.

The wiki page for it was found here: [url]http://doc.silverstripe.com/doku.php?id=hide-ancestor[/url]

Cheers,
Sean

Avatar
freeyland

6 August 2007 at 10:06pm Community Member, 22 Posts

I checked SiteTree.php and the code is the same as in the posted forum thread. I also added the quotes but the page 'Productgroup' is still available.

$instance = singleton($class);
if((($instance instanceof HiddenClass) || !$instance->canCreate()) && ($class != $this->class)) continue;

$addAction = $instance->uninherited('add_action', true);
if(!$addAction) $addAction = "a $class";