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   2866 Views

Avatar
janulka

Community Member, 80 Posts

10 March 2009 at 7:39am

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

126 Posts

10 March 2009 at 2:30pm

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

Community Member, 164 Posts

29 May 2009 at 8:30pm

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

Community Member, 224 Posts

31 October 2009 at 7:27pm

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

Avatar
steve_nyhof

Community Member, 224 Posts

31 October 2009 at 7:31pm

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

Community Member, 164 Posts

31 October 2009 at 8:58pm

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

Community Member, 224 Posts

1 November 2009 at 3:24am

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

Avatar
MarijnKampf

Community Member, 164 Posts

1 November 2009 at 4:21am

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

Go to Top