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.

Data Model Questions

ModelAdmin mit PageTypes


2 Posts   323 Views


18 August 2013 at 11:15pm Community Member, 23 Posts

Hey guys,

i want to handle all my newsPages in the ModelAdmin of SS3. The news are extended from Page and not DataObject.
I just created a ModelAdmin and also can see all my NewsPages there. i also defined that one newsPage can have only one newsHolder and a newsHolder can have many newsPages.

There are two problem right now:
- is if I create a new newsPAge in tehe modeladmin and save it, it is still unpublished and doesn´t show up on the wbesite.
- the other problem is that there is nothing where i can choose the place for the newspage to be. i would expect a dropdown where i can select all availabe newsHolders or something like that.

Any ideas?

Thanks in advance,


27 August 2013 at 11:57pm (Last edited: 28 August 2013 12:04am), Community Member, 1 Post

Please correct me if better solutions are available. The code below is what worked for me.

Save and publish should be available from betterbuttons for gridfield:

This is the solution I found to place the NewsPages under the NewsHolder:

function onAfterWrite(){
   $parentID = DataObject::get_one('NewsHolder')->ID;
   if($this->ParentID != $parentID)
      $this->ParentID = $parentID;

Disables creating more than one NewsHolder (recommended):

public function canCreate() {
   return DataObject::get_one('NewsHolder') ? false : true;

I chose to hide NewsHolder from SiteTree by adding css class to NewsHolder in SiteTree (and hiding .nositetree with css):

public function CMSTreeClasses() {
   return parent::CMSTreeClasses() . ' nositetree';

Hiding NewsPages from NewsHolder in SiteTree (optional):