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


Reply

3 Posts   689 Views

Avatar
bartvanirsel

19 March 2011 at 12:54am Community Member, 94 Posts

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

30 March 2011 at 11:41pm Community Member, 598 Posts

Hi Bart,

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

static $default_child = 'DefaultPageClass';

Aram

Avatar
bartvanirsel

1 April 2011 at 10:10pm Community Member, 94 Posts

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