Jump to:

5514 Posts in 1733 Topics by 1219 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Manipulate AddPageOptionsForm in CMS

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

Page: 1
Go to End
Author Topic: 673 Views
  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Manipulate AddPageOptionsForm in CMS Link to this post

    Hi,

    I'm looking into changing the default selected option in AddPageOptionsForm for creating new pages.

    Is this posible to set in (php) code? I tried some JQuery but that didnt work out.

    Behaviour.register({
    '#Form_EditForm' : {
    initialize : function() {
    this.observeMethod('PageLoaded', this.adminPageHandler);
    this.adminPageHandler();
    },
    adminPageHandler : function() {

    jQuery("#Form_AddPageOptionsForm_PageType option")
    .each(function() {
    if (jQuery(this).val() == 'DefaultSelectedPage')
    {
    jQuery(this).attr('selected', true);

    }
    });

    }
    }
    });

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Manipulate AddPageOptionsForm in CMS Link to this post

    Hi Bart,

    I think if you add this to your Page class it should do the trick:

    static $default_child = 'DefaultPageClass';

    Aram

  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Re: Manipulate AddPageOptionsForm in CMS Link to this post

    Hi Aram,

    Thanks, I'll try that out as well.

    In the end i managed to do this by doing it with javascript (jQuery) ::required by LeftAndMain.
    [[PageTypeToBeDefault]] is the default page.

    Behaviour.register({
    '#Form_EditForm' : {
    initialize : function() {
    this.observeMethod('PageLoaded', this.adminPageHandler);
    this.adminPageHandler();
    },
    adminPageHandler : function() {

    jQuery("#Form_AddPageOptionsForm_PageType option")
    .each(function() {
    if (jQuery(this).val() == '[[PageTypeToBeDefault]]')
    {
    jQuery(this).attr('selected', true);
    }
    });

    }
    }
    });

    Bart

    673 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.