In our continuing series covering new features and enhancements in Mura CMS version 6.2 we will explore another robust improvement, the Export and Import Class Extensions feature set, which has automated the process of transferring Class Extensions and Extended Attributes from one Mura site to another. We will also take a look at the overall Class Extension management system in Mura, with a few basic examples of these features put to use.
The term "class extension" is borrowed from the world of object-oriented programming (OOP). OOP provides a model for programming based on objects. These objects are designed in heirarchies, commonly a "class" heirarchy. Hence, "class extensions" is a term used to define user-created subclasses.
Any of the default Mura object types (User, User Group, Page, Folder, Gallery, Form, etc) can be extended with custom subtypes, known as Class Extensions. Creating a Class Extension allows you to add your own custom meta data or form fields that you can use to collect additional information. This custom meta data or form fields are known as "Extended Attributes."
While the default "content" types are designed with comprehensive options, allowing for management of everything from text and image content to meta-tags and SEO-specific titles on each content item, there are many situations in which additional, custom attributes are called for. For example, items in a catalog may include custom data such as the item's price and part number. Or, a listing of customer testimonials may include the customer's name and company in addition to the standard attributes of a Mura page.
Rather than including this additional information in the built-in content attributes such as the Body, Summary or Title, Mura's extended attribute system dynamically generates additional input fields within the Edit Content form, allowing for custom data to be managed and edited separately, and displayed as a unique string or value when output in a Mura template.
In addition, Extended Attributes may be applied to the existing "Default" subtype of any object class. This also applies the Extended Attributes to any Class Extensions of that class. For example, attributes added to "Page/Default" will be rendered on any subtype of that class, such as "Page/Testimonial."
With custom Class Extensions, the possibilities for managing and replicating any type of content or data objects in Mura are virtually endless.
Custom subtypes or Class Extensions and Extended Attributes are most commonly created and managed using the Class Extension Manager interface (found in the Mura Site Manager under the "Site Config" menu when logged in as a user with "Super" Admin permissions). The use of this interface to create a Class Extension and any Extended Attribute Sets is covered in detail in the Mura CMS documentation: Create a Class Extension.
The robust Extended Attribute area includes options for all standard form input types, such as text areas, checkboxes, file upload options or select lists, as well as a number of validation options which control not only the allowed values for these fields in the Edit Content interface, but also customized inputs such as a date picker or color selector.
These extended attributes are grouped into sets (think "fieldset"), and each set can be displayed on any tab of the Edit Content interface, allowing for easy access to the custom information along with the standard editable details in the site manager.
In addition to the built-in interface, Extended Attributes may also be created using a specific XML syntax as part of the theme's configuration file, config.xml.cfm, located at the root of the theme folder. The same syntax using the <extensions> xml object is also commonly found in Mura plugins, where custom functionality depends on specific attributes applied to specific content subtypes. The contents of these files are automatically read by Mura, and the custom class extensions and extended attributes are added to the available options in the site manager, just like those created using the Class Extension interface.
With the release of Mura 6.2, yet another option for defining and managing these custom subtypes and attributes has been added, simplifying the process of creating and reusing class extension definitions through a simple export dialog.
This new option is useful when setting up a new site, or replicating the functionality of an existing Mura site in another site or a plugin. Rather than hand writing or using the interface to recreate the XML syntax defining the custom subtypes and attributes, the export system generates the XML automatically. In addition to migrating class extensions to other sites, this feature can also be used to create a new class extension based on existing one by editing the XML subtype and attributes to create a similar but separate class extension and attribute set.
To demonstrate the basic usage of a class extension with extended attributes, we will use a simple "Customer Testimonials" display, which shows a photo of the customer and their testimonial, along with the customer's name and the name of their company.
In this example, the photo and the testimonial use the default attributes for an associated image and the page summary, respectively, while the customer name and the name of the company are contained in custom Extended Attributes. These can be seen in the site manager when editing or creating a content item with the custom subtype, or class extension, of "Page / Testimonial".
For purposes of example, we will export this simple class extension and small attribute set using Mura's Export Class Extensions dialog. This new feature allows for the export of any single class extension, as well as combining any or all of the existing class extensions, for granular control over the exported contents.
Upon selecting the Page/Testimonial class extension and clicking "Export", the dynamically generated XML is displayed in plain text format where it can be easily copied from the screen, along with a simple download button, to save the exported content as an XML file which can be edited or imported elsewhere.
Once the XML has been copied to the clipboard, or the .xml file has been saved using the "Download" option, importing or duplicating these custom settings in another location requires only a few more quick steps. We'll take an in-depth look at that part of the process in our next article.
Also see Mura CMS v6 Documentation: Create a Class Extension and Export a Class Extension Further documentation for Mura CMS developers and content managers is available at docs.getmura.com. Learn more about Mura's powerful features and flexible options at getmura.com.