# FirstSpirit Metadata Templates and Properties ## Overview Metadata in FirstSpirit provides additional information about objects beyond their primary content. This includes both system-assigned metadata (modification dates, version numbers, editing users) and user-defined metadata that can be customized through metadata templates. ## What is Metadata? Metadata consists of "additional information available for an object in FirstSpirit." It serves two primary purposes: 1. **System-assigned metadata**: Automatically generated information such as: - Last modification date - Editing user - Release authorization status - Version numbers - Integrated media counts 2. **User-defined metadata**: Custom information managed by users through the Metadata tab, requiring: - A metadata template definition - Appropriate permissions in Permission Management ## Metadata Template Configuration ### Creating a Metadata Template A metadata template must be created as a **page template** in the Template Store. The setup process involves: 1. Create a page template in the Template Store 2. Define input components with unique identifiers 3. Select the template in ServerManager's project properties 4. The template becomes available across all SiteArchitect stores Once configured, the "Metadata" tab appears in SiteArchitect, allowing editors to input content using the defined input components. ### Visual Indicators Nodes with specifically assigned metadata display a metadata icon after the object name in the tree structure, making it easy to identify which elements have metadata configured. ## Accessing Metadata Information ### The .meta() Method To output metadata variable content in template sets, use the system object `#global` with the `.meta()` method: ```java $CMS_VALUE(#global.meta("metadata_identifier"))$ ``` Each input component in the metadata template receives a unique identifier that is used to access its value. ### Example: Accessing Metadata Variables ```java // Access a simple text metadata field $CMS_VALUE(#global.meta("author"))$ // Access a date metadata field $CMS_VALUE(#global.meta("publish_date"))$ // Access a checkbox metadata field $CMS_VALUE(#global.meta("featured"))$ ``` ## Metadata Inheritance FirstSpirit provides three inheritance options that control how metadata behaves in the content hierarchy: ### 1. No Inheritance (none) ```xml ``` No inheritance from parent nodes occurs. Only the metadata defined on the current node is used. ### 2. Inherit from Parent (inherit) ```xml ``` If the current node lacks metadata, the system searches parent nodes upward in the hierarchy until a value is found. **Evaluation methods:** - **Current node only**: Returns value if populated; empty string otherwise - **Hierarchical inheritance**: Checks current node first, then searches parent nodes upward ### 3. Additive Inheritance (add) ```xml ``` Processes all nodes from root downward, aggregating metadata and outputting values separated by delimiters. **Important**: With additive inheritance, editors see only metadata defined on the current node, not inherited metadata, which can potentially cause user errors. ## Important Constraints and Behaviors ### Language Independence Metadata is **not language-dependent**. Only fallback definitions (`lang="*"`) apply to input component labels. This means metadata values are shared across all language variants. ### Component Behavior Limitations Some input components cannot be emptied once populated: - `CMS_INPUT_DOMTABLE` - `CMS_INPUT_DOM` - `CMS_INPUT_RADIOBUTTON` ### Metadata Status The metadata information icon appears in the project tree only after saving an input. The Metadata tab indicates whether data has been set via checkbox status. ## ELEMENTTYPE Property The ELEMENTTYPE property checks which element type a form was opened on, enabling dynamic form behavior based on context. ### Syntax ```xml ``` The `source` attribute must be set to `#global` since it's a system-level property. ### Supported Element Types The property returns lowercase type names corresponding to API interface names: **Page Store:** - `pagestoreroot` - `pagefolder` - `page` - `section` - `sectionreference` **Media Store:** - `mediastoreroot` - `mediafolder` - `file` - `picture` **Site Store:** - `sitestoreroot` - `pagereffolder` - `pageref` **Global Content Area:** - `globalcontentarea` - `gcapage` ### Usage Context This expression works in two areas: 1. **Value determination** (`` section) 2. **Preconditions** (`` section) ### Practical Example: Conditional Metadata Display Show specific form elements only for picture elements: ```xml picture ``` This rule makes the "st_metamedia" form content visible only when editing image metadata, hiding it on other element types. ### Example: Different Metadata for Different Element Types ```xml page section ``` This shows content-specific metadata fields only for pages and sections. ## TEMPLATE Property The TEMPLATE property retrieves the reference name (UID) of the template associated with template-based elements like pages, sections, and datasets. ### Syntax ```xml ``` ### Key Characteristics **Source Attribute**: Must use `source="#global"` since this is a universally applicable property. **Scope Behavior**: - When applied to a page, it returns page template information even if executed within nested components (like paragraphs in FS_CATALOG) - For metadata, it returns information about the element where the metadata was defined ### Usage Contexts This property works within: - Value determination sections (``) - Precondition definitions (``) ### Example: Storing Template Information ```xml ``` This rule captures the template identifier during lock operations and assigns it to a value property. ### Example: Template-Specific Metadata Fields ```xml news_article ``` This displays article-specific metadata fields only when the page uses the "news_article" template. ## Practical Metadata Usage Examples ### Example 1: Basic Metadata Template ```xml ``` ### Example 2: Accessing Metadata in HTML Output ```html $CMS_VALUE(#global.meta("st_title"))$ $CMS_IF(#global.meta("st_noindex"))$ $CMS_END_IF$ ``` ### Example 3: Conditional Metadata Based on Element Type and Template ```xml page picture page news_article ``` ### Example 4: Media Metadata Template ```xml picture ``` ### Example 5: Accessing Metadata with Fallback ```java // Access metadata with fallback value $CMS_SET(author, #global.meta("st_author"))$ $CMS_IF(!author.empty)$ $CMS_ELSE$ $CMS_END_IF$ ``` ## Permissions and Editing ### Permission Requirements Users can only modify metadata in edit mode with special permissions assigned through Permission Management. Without proper permissions, the Metadata tab will be read-only or unavailable. ### Accessing Metadata in Edit Mode 1. Open an element in edit mode 2. Navigate to the Metadata tab 3. Input or modify metadata values 4. Save to persist changes The Metadata tab indicates whether data has been set via checkbox status, providing visual feedback on which fields contain values. ## Best Practices 1. **Use inheritance wisely**: Choose the appropriate inheritance mode based on your content structure: - Use `inherit` for properties that should cascade down (e.g., author, copyright) - Use `add` for cumulative properties (e.g., keywords, tags) - Use `none` for page-specific properties (e.g., noindex flag) 2. **Language-independent design**: Remember that metadata is not language-dependent. Design your metadata schema accordingly. 3. **Conditional visibility**: Use ELEMENTTYPE and TEMPLATE properties to show relevant metadata fields for specific contexts, improving editor experience. 4. **Fallback values**: Always handle cases where metadata might not be set, providing sensible defaults. 5. **Clear labeling**: Use descriptive labels in LANGINFO sections to help editors understand what each field is for. 6. **Component selection**: Be aware that some components (CMS_INPUT_DOMTABLE, CMS_INPUT_DOM, CMS_INPUT_RADIOBUTTON) cannot be emptied once populated. Choose components carefully. 7. **Visual feedback**: Remember that the metadata icon only appears after saving, so inform editors about this behavior. ## Summary Metadata templates in FirstSpirit provide a powerful way to attach additional information to content elements. By leveraging: - The `.meta()` method for accessing metadata values - Inheritance options for hierarchical content structures - ELEMENTTYPE and TEMPLATE properties for conditional display - Form rules for dynamic metadata forms You can create flexible, context-aware metadata systems that enhance content management and output generation across your FirstSpirit projects.