Macro "Content by Metadata" (v 3.3)

   SINCE VERSION 3.0

In order to insert macros in Confluence, you need to possess editor permissions for the page.

There are several macros you can use to display metadata in Confluence or to select pages on the basis of their metadata. This page will show you how to use the Content by Metadata macro.

Introduction

The Content by Metadata macro is used to display the page metadata of multiple pages in a list according to a search criterion.

An example result can be seen in this preview:

edit mode of the content by metadata macro showing a preview of a simple list of page titles as linksImage 1: Content by Metadata Macro (click to enlarge)


The search criterion is defined by filtering for metadata fields and certain values of those fields or metadata sets. Details on using the CQL dropdown filters are described in Searching with Metadata (v 3.3) and the next section.

 If you want to search for more detailed information, open the expert filter criteria by clicking "Show". This will allow you to, among other things, filter for metadata sets, filter for Confluence spaces or create more complex search queries using CQL search. Find detailed instructions on how to generate these queries in Searching with Metadata and some additional information in the next section.
The Metadata Overview will then only show search results that match the expert filter criteria AND selected filters.

You can find more detailed information on the available parameters in the next section.

Parameters

The following parameters are available for the Content by Metadata macro. To display all of the parameters, click "Show" next to the heading "Options".

ParameterDefaultDescription
FiltersNoneOptionalDefine metadata fields and metadata field values, and metadata sets to filter results displayed in the metadata overview macro. Can be left empty if expert filter criteria is used (see next parameter).
Expert filter criteria (CQL)NoneOptional

Define more comprehensive filter queries to filter results displayed in the metadata overview macro. Can be left empty if Filters are used (see prior parameter).

Expert filter criteria are defined using the metadata sets and field keys and the CQL search syntax. Please also see Determining the key of a Metadata set or field.

Placeholders are supported to make the output of the macro more dynamic.

The following parameters are available:

  • The current page object by using the placeholder $content
    • Example: to show all content with a global Metadata field of type LINK which links to the current page

      global.metadatafield.linkfield = "PAGEID:$content.id"
       Other dynamic variables available

      $user.name 
      
      Current logged in users username
      $user.key 
      
      Current logged in users userkey
      $user.email 
      
      Current logged in users email adress
      $user.fullName 
      
      Current logged in users full name
      $content.contentId 
      
      The id of the current page/blogpost
      $content.id 
      The id of the current page/blogpost
      $content.type 
      
      The type of the current page/blogpost
      $content.displayTitle 
      
      The title of the current page/blogpost
      $content.space.name 
      
      The name of the current space
      $content.space.key 
      
      The spacekey of the current space
      $content.space.lowerKey 
      
      The spacekey of the current space
      $content.space.type
      The type of the current space

Expert filter criteria (Lucene)

DEPRECATED

NoneOptional

Define more comprehensive filter queries to filter results displayed in the Content by Metadata macro. Can be left empty if filters are used (see prior parameter).

Expert filter criteria are defined using the metadata sets and field keys and the Lucene search syntax. Please also see Determining the Key of a Metadata Set/Field.

Placeholders are supported to make the output of the macro more dynamic.

The following parameters are available:

  • The current page object by using the placeholder $content
    • Example: to show all content with metadata links to the current page

      metadatafield.linkfield:$content.id
  • The current user object by using the placeholder $user
    • Example: Show all pages with the current logged in user defined in a metadata field

      metadatafield.userfield:$user.name
  •  Other dynamic variables available

    $user.name 
    
    Current logged in users username
    $user.key 
    
    Current logged in users userkey
    $user.email 
    
    Current logged in users email adress
    $user.fullName 
    
    Current logged in users full name
    $content.contentId 
    
    The id of the current page/blogpost
    $content.id 
    The id of the current page/blogpost
    $content.type 
    
    The type of the current page/blogpost
    $content.displayTitle 
    
    The title of the current page/blogpost
    $content.space.name 
    
    The name of the current space
    $content.space.key 
    
    The spacekey of the current space
    $content.space.lowerKey 
    
    The spacekey of the current space
    $content.space.type
    The type of the current space

Sort by
Page title ("title")OptionalDefines the metadata field whose values will determine the sort order of all entries.
Sort DirectionASCENDINGOptionalDefines the sort direction of the table entries according to the values entered in the "Sort by column" column.
Number of items to display20Optional

Defines the maximum amount of pages that are to be displayed in the macro. If the filter results contain more items, the output will be cut off. The parameter "Show more results" can be set (see below).

(info) The maximum supported number is 250 items.

Show key of spaceUncheckedOptionalShow the space key of the space where the page is located. It will be displayed in brackets behind the title.
Show more resultsUncheckedOptionalDisplays a "load more" link at the bottom of the list.

Permissions

Content will be found across all (permitted) spaces. This means that search results are not limited to the current space unless you filter for a space within the parameter "Expert filter criteria".

The search results are filtered according to the permissions of the logged-in user. This means that you will only see pages you are allowed to access in the Content by Metadata macro.

If the page or space is not otherwise restricted, pages that can be accessed anonymously will appear for anonymous users.

Use Cases for Expert Filter Criteria

1) Example from the Metadata demonstration space "Product Directory" - show all pages with the Metadata set "Product Info" (Metadata set key "democaseproductinfo"), which are part of the space "Product Directory" (space key "DEMOCASEPRODDIR"):

metadataset = metadataset.democaseproductinfo AND space = DEMOCASEPRODDIR

2) Personalization of Confluence content with the help of User Profiles for Confluence - show an overview of all pages with the metadata set "Product Info" where the metadata field "Technology" equals the content of the user profile field "Responsible for technology" of the current user:

metadataset = metadataset.productinfo AND DEMOCASEPRODDIR.metadatafield.technology = "upc.currentUser"

For further explanations of this use case, please see How to Get Started. Available options for placeholders are described in the section Parameters above.

You can find further details on basic and complex search queries as well as determining the correct field or set keys in Searching with Metadata.



Back to Top