Hello,
Is there a way to have textfield for Title from Content -> Meta-data appear under the Content -> Main tab instead?
Thank you!
J.
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hello,
Is there a way to have textfield for Title from Content -> Meta-data appear under the Content -> Main tab instead?
Thank you!
J.
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
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 )
The Title shows up fine, but it is not at the top. Any ideas how to get it to the top?
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!
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
Thank you for the info. Where can I find the complete docs like this?