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 /

Manipulate AddPageOptionsForm in CMS


Go to End
Reply


3 Posts   800 Views

Avatar
bartvanirsel

Community Member, 96 Posts

19 March 2011 at 12:54am

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);

                    }
            });

        }
    }
});

Avatar
Carbon Crayon

Community Member, 598 Posts

30 March 2011 at 11:41pm

Hi Bart,

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

static $default_child = 'DefaultPageClass';

Aram

Avatar
bartvanirsel

Community Member, 96 Posts

1 April 2011 at 10:10pm

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