Class Extensions - Mura Docs v7.0

Class Extensions

Mura's Class Extensions allow you to customize some of its common bean objects such as content beans, user beans, group beans, and site beans. The term "class extension" itself is borrowed from the world of object-oriented programming (OOP). These "objects" are designed in hierarchies, commonly referred to as a "class" hierarchy. Hence, "class extensions" is a term Mura uses to define custom subclasses.

Class extensions allow you to create Extended Attribute Sets (think fieldsets, or groups of related form elements) to provide additional "attributes" (think form fields) to collect and store data. In addition, you can create Related Content Sets to allow content managers the ability to associate content to something other than the default catch-all "Related Content" field, allowing you to create fields such as Related Videos, Related Files, Related Authors, and so on.

Also, class extensions provide an excellent way to allow developers the ability to target a certain Type and/or Subtype of a content item's body area, so they can do things such as automatically alter the layout of the body area, and/or include additional data, etc. Using this method means you wouldn't necessarily have to create any Extended Attribute Sets or Related Content Sets either, unless that's something you desire.

Types & Subtypes

Each of the bean objects Mura exposes for customization (see table below) include two very important attributes: Type, and Subtype. While you can change the Subtype attribute of a bean object, you cannot alter the Type attribute itself.

When working with class extensions, you first target the specific Type for customization. Then, you target the "default" Subtype, or create a new Subtype altogether. These are often represented as {Type}/{Subtype} when creating new objects. For example, "Folder/Locations", "Page/Location", "User/Employee", etc.

While the options for customization are essentially limitless, here are a few examples to help illustrate how you might use class extensions.

  • User
    • You could create a new "User" subtype, such as "Employee". Then, you might want to collect additional data about the employee such as "Emergency Contact Name", "Emergency Contact Mobile", etc.
  • Folder
    • You could create a new "Folder" subtype, such as "Locations". Then, you could target any content items using "Folder/Locations" as the Type and Subtype in order to loop over any child content items and display them on a map. You wouldn't necessarily have to add any Extended Attribute Sets or Related Content Sets either. As you'll see in the Define with the Admin UI section, you can also restrict the {Type}/{Subtype} of content that can be added as children.
  • Page
    • Along the same lines of the previous Folder example, you could create a new "Page" subtype, such as "Location". Then, you could collect data about the location such as the Street, City, State, Phone Number, etc. and display the information entered into these fields on the page when it's being rendered. In addition, you could use this data to geocode the location for use on map.

The "default" Subtype

By targeting "default" as the Subtype, any Extended Attribute Sets or Related Content Sets associated with the class extension will apply to all objects sharing the same Type attribute.

For example, if you create a new class extension and the Type equals "Page" and Subtype equals "Default", then anything you create will apply to all "Page/Default" content items, as well as any other "Page/{Anything}" content items.

Extendable Bean Objects

The table below itemizes each of the "Base Types" of bean objects available for customization.

Type Bean Description
Page content This is the standard Page content type.
Folder content This is the standard Folder content type.
File content This is the standard File content type.
Calendar content This is the standard Calendar content type.
Link content This is the standard Link content type.
Component content This is a standard Component, which is essentially a special type of content itself. Using Class Extensions with Components opens several possibilities such as creating a Component with tabbed content, slideshows, and more.
Form content This is a standard Form, also a special type of content.
Base content Extending the Base/Default object allows you to create additional Extended Attribute Sets and Related Content Sets to appear on all standard content types (Page, Folder, File, Calendar, and Link), excluding Components and Forms. If you specify a different Subtype, then any Extended Attribute Sets or Related Content Sets will only appear on content types that share the specified Subtype.
User (2) user Since the group bean is essentially the user bean, the type attribute for users is technically stored as a "2" to indicate the record reflects a "user".
Group (1) group Since the group bean is essentially the user bean, the type attribute for groups is technically stored as a "1" to indicate the record reflects a "group".
Address address Address bean objects are related to user beans. A user may have one or more addresses. By extending this class, you can create additional attributes to store new types of data that Mura doesn't already collect.
Site site Extending the Site object allows you to create additional Extended Attribute Sets via the Site Settings area of the back-end administration area of Mura.