Removing the ‘Content’ part from HomePage ‘Page Type’

We had a code for HomePage pagetype like so:

<?php
class HomePage extends Page {
    static $db = array(
	'Description' => 'Text'
    );
    static $has_one = array(
	'Photo' => 'Image'
    );
    function getCMSFields() {
        $fields = parent::getCMSFields();

        $fields->addFieldToTab('Root.Content.Main', new ImageField('Photo'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextField('Description'), 'Content');

        return $fields;
    }
}
class HomePage_Controller extends Page_Controller {
}
?>
  1. For Removing the content u need to remove the content from the main tab using code:
    <?php
    class HomePage extends Page {
        static $db = array(
    	'Description' => 'Text'
        );
        static $has_one = array(
    	'Photo' => 'Image'
        );
        function getCMSFields() {
            $fields = parent::getCMSFields();
            $fields->removeFieldFromTab("Root.Content.Main","Content"); // removes the content from cms tab
            $fields->addFieldToTab('Root.Content.Main', new ImageField('Photo'), 'Content');
            $fields->addFieldToTab('Root.Content.Main', new TextField('Description'), 'Content');
    
            return $fields;
        }
    }
    class HomePage_Controller extends Page_Controller {
    }
    ?>
  2. After changing the code use yoursite.com/dev/build?flush=1

Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , | Posted under SilverStripe CMS | RSS 2.0

Author Spotlight

Teet Bergmann

Teet Bergmann

I'm a freelance web designer from Estonia. Mostly doing sites using Silverstripe, magento, prestashop, wordpress.

Leave a Reply

Your email address will not be published. Required fields are marked *


8 − 7 =

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>