Attach custom information to any page or Mura CMS content item using "Class Extensions" to create extra editable attributes. Mura's Extended Attributes system allows for virtual database columns to be added and manipulated, without writing any code at all.
One of the great things about a CMS is that it stores all of your website information into a single database (like an Excel spreadsheet), and gives you easy access to edit that information in the admin. When you edit a page's title, summary, or body copy, and click publish, you're essentially updating that database with the changed information. But what if you want to store additional information associated with a particular content type?
A profile page, for example, might contain a repetitive structure of information about that person (First Name, Last Name, Job Title, etc). Traditionally your options would be to re-type all of that information every time, or you would have to either alter the database (either directly, or write some custom scripts to do that for you) to create additional columns to contain that information. Then you would have to alter the user interface (UI) to give the user additional form fields to input that information..
In Mura CMS, that entire process is simplified with the use of Extended Attributes. In the Mura admin, you can extend just about any content node type (Page, Component, Gallery, Folder, etc) and add as many extra fields you want, all without having to touch the database or write any code.
In this example, we're going to create a new page type for a book. In addition to the title, each book will have the following fields for the content administrator to fill out:
There are three parts involved in Creating Extended Attributes:
The first step is to create the Class Extension. This is the main object Type andSubType that will house all of the extended attributes.
To create a new Class Extension::
Now that you have your Page/Book Class Extension, we need to add a few Extended Attributes for the items we need for the book. Extended Attributes are grouped into Attribute Sets, much like a <fieldset>
in an HTML form). The attribute sets are separated visually in the admin to allow modular separation for the user.
To create an Attribute Set:
Once you have your Attribute Set created, you can add the individual Extended Attributes. We will start by adding a plain text field for the book's author:
For the remaining fields, repeat the steps above with the following details for each field:
Now that you have created all of your extended attributes, you can add a new book from the site manager, and fill out all of the form fields you just created.
When you view the page, you will notice that your attributes are not showing up. That is because we need to tell Mura to display those values out on the page. Now, there are several ways to accomplish this, all depending on the use case and how much flexibility you want to give your users to change the page layout. In this example, we are going to create a component that outputs the information we want, so that way it's versatile to use in whatever page template we choose.
Now when you refresh your book page, you should see the book details appear in the right-hand sidebar.
As I mentioned before, this is merely one way to display Extended Attributes. You may also choose to incorporate your extended attributes in your page or component templates, where you can use additional logic and further prevent your users from altering your markup.
If you would like to display your Extended Attributes within a template, simply change the [ m ]
to #
e.g. #$.content('bookAuthor')#
The [ m ]
tag is part of the Mura Scope to allow you to display certain Mura functions within the editor in the admin, where as the hashtags (#
) are the standard way of outputting content in CFML.
Now that you've learned how to use Class Extensions, you can take your Mura themes to a whole new level by giving your users more robust ways to manage the content in your themes.
Also see Mura CMS Documentation: Class Extension Manager