November Happy Hour will be moved to Thursday December 5th.

Hide category property?

Vote:
 

Is it possible to hide the category property on a specific pagetype in CMS7?

#63438
Nov 20, 2012 9:07
Vote:
 

Sure you can. In your project, create and register a new editor descriptor for CategoryList. Override ModifyMetadata method to check if the owner content is of that page type then set ShowForEdit to false.

Some thing like this:

[EditorDescriptorRegistration(TargetType = typeof(CategoryList))]
public class NewCategoryEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(Shell.ObjectEditing.ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
var ownerContent = ((ContentDataMetadata)metadata).OwnerContent;
if (ownerContent is StandardPage)
{
metadata.ShowForEdit = false;
}
}
}

#63650
Nov 23, 2012 9:30
Vote:
 

Duong, ContentDataMetadata resides in EPiServer.Cms.Shell.UI.dll which is located in the modules (packaging) VPP. Out of curiousity, is it recommended to add a reference to that assembly? If so, that means that the modules VPP must be checked in into source control or the project won't build for other devs. Maybe that's not an issue, but I'd be really interested to hear your/EPiServer's view on this.

#63722
Nov 27, 2012 15:50
Vote:
 

Joel, there was a nice discussion among us and the addon team. We came up with conclusion that since it depends on an addon (Sparrowhawk), it should also be an addon so the site will be able to update.

That would be my best suggestion for now.

#63727
Nov 27, 2012 17:41
Vote:
 

I can imagine :)

Not solving the greater problem of referencing Sparrowhawk assemblies an alternative solution here may be to use a duck.

public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
  dynamic mayQuack = metadata;
  var ownerContent = mayQuack.OwnerContent as IContent;
  
  if (ownerContent is StandardPage)
  {
    metadata.ShowForEdit = false;
  }  
}

    

#63735
Nov 28, 2012 9:23
Vote:
 

Very neat solution for the original problem. I assume DLR's performance is not a big issue.

#63754
Nov 28, 2012 15:55
Vote:
 

Nice solution. I always wondered why it is enabled by default (I don't like showing unused and thus confusing functionalities), but have always more important stuff to work on. I found this topic by accident, but already implemented in my project. Thanks!

#66559
Mar 05, 2013 9:08
Vote:
 

Works well for me. How about if i just wanted to change which tab the category appears on. At the moment it always shows in the content tab, not even in a categories tab. I would like to move it to the settings tab.

 

Thanks

#66569
Mar 05, 2013 12:52
Vote:
 

metadata.GroupName = SystemTabNames.Settings should do the trick.

#66570
Mar 05, 2013 12:56
Vote:
 

ah. simple. thanks joel

#66571
Mar 05, 2013 13:02
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.