Profiles and Custom Assets
Profiles and Custom assets are two separate concepts, but work really well together - in fact there isn't much use for assets without profiles.
Profiles
Profiles are a way to extend CMS content objects by adding custom data fields to them. For example if you have a food-related site in which some articles contain recipes, then it would make sense to categorize them: salads, soups, main courses etc. and perhaps add an estimated time to prepare the dish. This is easily achieved by creating a profile for articles that adds those fields so the editor can fill them and the site could display and search this information.
Profiles can be created in the Admin section from System > Profiles menu. First choose the object type from the left pane, in our example this would be the "Article" and then from the "New" buttons dropdown choose "Profile". To create you own data fields for the profile, choose the profile from the left pane and then from the "New" button dropdown "Data Field" option.
View: the "recipe" profile with 2 custom fields
View: the "course_type" field definition
View: the "estimated_time" field definition
View: the article editor with the profile
A sample code for the template would be:
{init_article name="article" profile="recipe"}
<h1>{$article->title}</h1>
Course: {$article->course_type}, estimated preparation time: {$article->preparation_time} minutes.
Not only is it possible to create profiles for CMS objects but also for external tables that begin with a "ext_" prefix in the database. The CMS requires 3 columns from an external table in order to use profiles:
- ID column, named "id"
- a name column, named "name"
- Profile ID column, named "profile_id"
There are {init_profile} and {save_profile} tags to display and save information for these tables available from version 4.4.3, but other than that the CMS does not in any way support this data contrary to assets.
Every table and object can have more than one profile, but beware of overlapping field names: you can't have different type of fields with the same name for the same object type or table.
Custom assets
Custom assets are essentially blank objects, they only have the basic attributes like every other CMS content object. It is up to you to create a suitable content and use them accordingly. Because assets are part of the CMS you will have all the benefits that come with the framework. The following applies to assets:
- Staging (publishing/hiding).
- Their title data is searchable using the site search.
- They are part of the site's hierarchical structure.
- You can use Saurus API tags to work with them in template code.
- Editors can change the data on custom assets in the similar way they working with any Saurus content object - v-shaped buttons allow to open system-generated popup windows for data entry.
The most simplest use for asset is to create a selector. In the recipe example the course_type is a text field, but the choices to be entered there are limited and so it should be a selection of predefined values. To achive this create a new profile under Custom Assets named "Course types", and give it a few values from System > Data menu, always save these kinds data pieces under the System section so they wont appear in the sitemap. And change in the "Recipe" profile the "course_type" to a select box which should take the values from "Course types" asset.
View: the "course_types" profile
View: the "course_types" profiles data
View: the modified "course_type" field in "recipe" profile
View: the article editor with the modified profile
The value stored with in the "Recipe" profile is the ID of the selected asset not the string. So if you change the title value of the asset the change will affect the whole site.
