Try our conversational search powered by Generative AI!

How to hide/remove 'Main Body' and 'Large content area' from editor?


I don't want to use these fields. How do I remove them? This seems like it should be way easier to do than it is. 

Oct 07, 2020 19:01

What about removing those from the content type definition (code) ?

Oct 08, 2020 4:40

Removing it from code is your first response. Don't want code (or properties) that isn't used. 

Other options are:

  1. Using the ignore attribute
    public virtual int ThisPropertyIsHidden { get; set; }​
    This will remove it in edit mode altogether. Note though that it won't be indexed by search either...
  2. Using the Editable attribute
    public virtual string NotEditableProperty {get;set; }​
    This will show the value to the editor but they can't change it
  3. Using the ScaffoldColumn attribute
    public virtual string HideThisPropertyFromEditors { get; set; }​
    Very similar to Editable attribute above. 
  4. Move the property to a tab that has higher access rights requirement

I would recommend using the Editable attribute normally if you want to have the property in the background but not allowing the editor to touch it.  

Edited, Oct 08, 2020 7:57

[ScaffoldColumn(false)] hides the property from the edit UI, but you can still work with it programmatically.

Oct 08, 2020 8:55

I tried a few of these methods. Removing the property seemed the most obvious, but no luck. I got frustrated and moved on to some other content types and the creation worked as I hoped. The long and short of it is that it seems somehow my original content type is cached somewhere. That type and other types all inherit from the same base class extended from PageData, but it is working as though the code hasn't changed since yesterday afternoon. 

The really strange thing, if I change the file and class name from TechnologyInstructionPage to TechnologyInstruction it works as exactly I hope it would. But then when I change back to TechnologyInstructionPage it has old properties showing up I've since deleted from the code and were in a parent class it is no longer inheriting from. It as though something is cached somewhere. This is a strange behavior that only changing the page name actually fixes it. I'd like to have all my content types with the "Page" string as end of file name for consistency, but if I do I end up with some old version of code executing. This is ... worrisome. I have no idea what is causing this.

Oct 08, 2020 17:59

A few things to note. Properties that have values are not removed. You can however "force remove" them from admin mode. Renaming a content type, without having specified an ID (which is hightly recommended by the way), will create a new type. So that's probably what you're seeing. 

Oct 08, 2020 18:04

Like Johan said, remember to set a guid on your page type otherwise renaming class will mess things up. If you check in admin you will see that you now have multiple page types (TechnologyInstructionPage and TechnologyInstruction) if you forgot to set that guid.

Oct 09, 2020 7:39
* 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.