Set default value of VisibleInMenu in PageTypeBuilder.

Vote:
 

I have a page type defined in PTB and for this particular page type, I want the pages to have the VisibleInMenu property set to false by default. But when I try to set VisibleInMenu = false in the constructor for my page type, I get the following error in Edit mode:

"Property 'PageVisibleInMenu' does not exist, can only assign values to existing properties"

A weird error message, since I'm not reaching for PageVisibleInMenu.

Any idea what the correct approach would be for changing the default value fo a property in a base class?

#60721
Aug 22, 2012 11:21
Vote:
 

If you mean in the page type attribut the correct propertyname would be "DefaultVisibleInMenu" (DefaultVisibleInMenu = false).

/Erik

#60725
Aug 22, 2012 13:09
Vote:
 

This was not exactly what I was looking for, but it definitely solves the specific VisibleInMenu problem. Thank you!

But what if it is another property. If I want new pages of my page type to have its "Link type" set to "Shortcut to page in EPiServer CMS" and the "Internal Shortcut/Fetch Data from" set to the parent page, how could I do that?

#60726
Aug 22, 2012 13:46
Vote:
 

Then I would attach an event to DataFactory.Instance.SavingPage in global.asax or a http module and do it from there.

 

Something like 

protected void Application_Start(Object sender, EventArgs e)
		{
			DataFactory.Instance.SavingPage += Instance_SavingPage;           
		}

		void Instance_SavingPage(object sender, EPiServer.PageEventArgs e)
		{
			if (e.Page is SomePageType)
			{
// Do magic
			}
		}

    

#60727
Aug 22, 2012 13:51
Vote:
 

OK, but what if I only want it to be default when creating a new page, letting the user alter the value if he wants to?

#60728
Aug 22, 2012 13:55
Vote:
 

Saving page was the wrong event, didn't think.. :)

LoadedDefaultPageData is what you are looking for (see http://antecknat.se/blog/2008/06/09/prepopulate-fields-when-creating-page/).

#60729
Aug 22, 2012 13:57
Vote:
 

Looks messy, but ok. Thanks for enlightening me!

#60731
Aug 22, 2012 14:33
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.