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.

Customising the CMS

move Title field from Meta-data to Main?


Go to End
Reply

9 Posts   2802 Views

Avatar
janulka

10 March 2009 at 7:39am Community Member, 80 Posts

Hello,

Is there a way to have textfield for Title from Content -> Meta-data appear under the Content -> Main tab instead?

Thank you!

J.

Avatar
Anatol

10 March 2009 at 2:30pm 126 Posts

Hi,

I guess that would be:

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Content.Main","MetaTitle");
$fields->addFieldToTab("Root.Content.Main", new TextField("MetaTitle", "Title"), "Content");
return $fields;
}

The "Content" is to place the Title field before the Content field, otherwise it would appear at the bottom.

Cheers!
Anatol

Avatar
MarijnKampf

29 May 2009 at 8:30pm Community Member, 164 Posts

For people new to SilverStripe like me, the code should be added to \mysite\code\Page.php

class Page extends SiteTree {

   public static $db = array(
   );

   public static $has_one = array(
   );

   /** Add code here **/
   function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->removeFieldFromTab("Root.Content.Main","MetaTitle");
      $fields->addFieldToTab("Root.Content.Main", new TextField("MetaTitle", "Title"), "Content");
      return $fields;
   }
}

After adding the code flush the DB ( http://localhost/dev/build?flush=1 )

Avatar
steve_nyhof

31 October 2009 at 7:27pm Community Member, 224 Posts

The Title shows up fine, but it is not at the top. Any ideas how to get it to the top?

Avatar
steve_nyhof

31 October 2009 at 7:31pm Community Member, 224 Posts

Now I like it at the bottom because it is blank to begin with. Once the Page name is given it is filled in. Good to go!

Avatar
MarijnKampf

31 October 2009 at 8:58pm Community Member, 164 Posts

In case you change your mind and want it at the top again, you can use the third parameter of addFieldToTab to determine the position. See http://api.silverstripe.org/forms/fields-structural/FieldSet.html#addFieldToTab

Avatar
steve_nyhof

1 November 2009 at 3:24am Community Member, 224 Posts

Thank you for the info. Where can I find the complete docs like this?

Avatar
MarijnKampf

1 November 2009 at 4:21am Community Member, 164 Posts

http://doc.silverstripe.org/doku.php

Go to Top