Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Move URL field to Main tab

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1729 Views
  • bmc38119
    Avatar
    Community Member
    45 Posts

    Move URL field to Main tab Link to this post

    Has anyone had any luck moving the URL field to the Main tab? I tried it about a month ago with no luck. i am pretty familiar with customizing the CMS tabs in the past, but cannot seem to get this particular field to move correctly. any tips would be appreciated.

  • MateuszU
    Avatar
    Community Member
    89 Posts

    Re: Move URL field to Main tab Link to this post

    What about something like below? I didn't try that, this is based on code that moves tabs around, so it might fail

    $segment = $fields->fieldByName('Root')->fieldByName('Content')->fieldByName('Metadata')->fieldByName('URLSegment');
    $fields->removeFieldFromTab('Root.Content.Metadata', 'URLSegment');
    $fields->addFieldToTab('Root.Content.Main', $segment);

    mat.

  • bmc38119
    Avatar
    Community Member
    45 Posts

    Re: Move URL field to Main tab Link to this post

    thanks for idea - but this method did not work. anyone else have any insight/experience with moving this Field to the Main tab?

  • DeklinKelly
    Avatar
    Community Member
    196 Posts

    Re: Move URL field to Main tab Link to this post

    This works for me:

    $fields->removeFieldFromTab('Root.Content.Metadata', 'URL');
    $fields->addFieldToTab("Root.Content.Main", new TextField('URLSegment','URL'));

  • Deklin
    Avatar
    Community Member
    16 Posts

    Re: Move URL field to Main tab Link to this post

    I tried the code posted by hknight and it moves the URL to the main tab however the field is no longer automatically filled by JavaScript. How can I get the JavaScript to auto-fill it after moving it?

  • TotalNet
    Avatar
    Community Member
    181 Posts

    Re: Move URL field to Main tab Link to this post

    You might need to update the script, it uses the id of the input element which may have changed after you moved it.

    The script is sapphire/javascript/UpdateURL.js

    either edit it or better still, block the requirement and add your own updated version of the script (in your getCMSFields).

    This is based on v2.4.0.

    hth

    1729 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.