This page last changed on Dec 02, 2008 by smaddox.

The Content by Label macro lists content which has been tagged with specific labels.

On this page:

Error formatting macro: toc: java.lang.NullPointerException

Recommended Basic Usage

To display all pages with the label needs-fixing, use:

{contentbylabel:label=needs-fixing|showLabels=false|showSpace=false|maxResults=99|key=@self}

Working Example of Usage

Below is a working example of the 'Content by Label' macro. In the example, we have restricted the display to 5 results. By default, Confluence lists all the labels for each result displayed. See the optional parameters below for more information.

What you need to type What you will get
{contentbylabel:label=documentation, my:stuff|maxResults=5}
contentbylabel: 'my:stuff' is not an existing label

Parameters

Parameter Default Description
label None This parameter is required.

Use this parameter to filter the results by label. The macro will display only the pages etc which are tagged with the label(s) you specify here.

You can specify one or more label values, separated by a comma or a space.
  • To exclude content which matches a given label, put a minus sign (-) immediately in front of that label value. For example: If you specify a label value of -badpage you will get only content which is not labelled with 'badpage'.
  • To indicate that the results must match at least one of the specified label values, simply list the labels separated by commas. For example: If you specify a label value of -badpage,goodpage,superpage you will get content which has a label of either 'goodpage' or 'superpage' (or both) but does not have the label 'badpage'.
  • To indicate that the results must match a given label value, put a plus sign (+) immediately in front of that label value. For example: If you specify a label value of +superpage,+goodpage you will get only content which has at least two labels, being 'superpage' and 'goodpage'.
labels   Exactly the same as label above.
max 15 Specify the maximum number of results to be displayed. Note that the results are sorted first, and then the maximum parameter is applied.
maxResults 15 Exactly the same as max above.
operator OR The operator to apply to the supplied lists of labels. By default, a page with any of the labels will be listed. By using operator=AND, only pages with all of the supplied labels will be listed.
showLabels true Show or hide labels for results
showSpace true Show or hide spaces for results
reverse false Use this parameter in conjunction with the sort parameter described below. Set reverse=true to change the sort from ascending to descending.

Note: this parameter is ignored if the sort parameter is not specified.
sort modified Specify how the results should be sorted. To change the sort order from ascending to descending, use the reverse parameter described above.

Note: If this parameter is not specified, the sort order defaults to descending order based on the last modification date.

Values:
  • creation — Sort by the date on which the content was added.
  • title — Sort alphabetically by title.
  • modified — Sort by the date on which the content was last updated.
space @self, i.e. the space which contains the page on which the macro is coded This parameter allows you to filter content by space. The macro will display only the pages etc which belong to the space(s) you specify here.

You can specify one or more space keys, separated by a comma or a space.
  • To exclude content in a specific space, put a minus sign (-) immediately in front of that space key. For example: If you specify a space key of -BADSPACE you will get only content which is not in the BADSPACE.
  • To indicate that the results must come from least one of the specified spaces, simply list the space keys separated by commas. For example: If you specify the space keys of YOURSPACE,GOODSPACE you will get content from both YOURSPACE and GOODSPACE.
  • To indicate that the results must come from a specific space, put a plus sign (+) immediately in front of that space key. For example: If you specify a space key of +GOODSPACE you will get only content in GOODSPACE. (Note that this is not particularly useful, because each content item belongs to one space only. If you put a plus sign next to one space key and list other space keys too, the other space keys will be ignored.)



Special values:

  • @self — The current space.
  • @personal — All personal spaces.
  • @global — All global spaces.
  • @favorite — The spaces you have marked as favourite.
  • @favourite — The same as @favorite above.
  • @all — All spaces in your Confluence site.
  • * — The same as @all above.

When specifying a personal space, remember to use the tilde (~) sign in front of the username, such as ~jbloggs or ~jbloggs@example.com.

spaces   Exactly the same as space above.
type all This parameter allows you to filter content by content type. The macro will display only the content of the type you specify here.

You can specify one or more types, separated by a comma or a space.
  • To exclude content of a given content type, put a minus sign (-) immediately in front of that content type. For example: If you specify a content type of -comment you will get pages, news items and all other content except comments.
  • To indicate that the results must be of a given content type, put a plus sign (+) immediately in front of that content type. For example: If you specify a label value of +comment you will get only comments. You will get the same results if you specify a single value of comment. (Note that this is not particularly useful, because each content item belongs to one content type only. If you put a plus sign next to one content type and list other content types too, the other content types will be ignored.)
  • To indicate that the results must match at least one of the specified content types, simply list the content types separated by commas. For example: If you specify a content type of comment,page you will get comments and pages.



Available values:

  • pagePages.
  • blogpostNews items, also known as blog posts.
  • news — The same as blogpost above.
  • commentComments on pages and news items.
  • mailEmail messages.
  • attachmentAttachments.

Note: Attachments, mail and comments cannot be labelled, and thus specifying those in the type parameter will always return no results.

Examples

1. Show content from a specific space

{contentbylabel:label=dogs,cats|space=PETS}

2. Show only results in current space

{contentbylabel:label=dogs,cats|space=@self}

3. Show results from all spaces

{contentbylabel:label=dogs,cats|space=@all}

4. Show only content of a specified type

The code below will show only pages (but not news items or other content types) with the labels 'dogs' or 'cats':

{contentbylabel:label=dogs,cats|type=page}

5. Do not show the labels in the results

{contentbylabel:label=dogs,cats|showLabels=false}

6. Do not show the space names in the results

{contentbylabel:label=dogs,cats|showSpace=false}

7. Display excerpts in the results

{contentbylabel:label=dogs,cats|excerpt=true}

8. Specify the maximum number of results to display

{contentbylabel:label=dogs,cats|max=99}

9. Sort by modification date

{contentbylabel:label=dogs,cats|sort=modified}

10. Change the sort order

{contentbylabel:label=dogs,cats|sort=modified|reverse=true}
RELATED TOPICS

Related Labels Macro
Navmap Macro
Recently Used Labels Macro
Working with Labels Overview
Working with Macros

Take me back to Confluence User Guide

Document generated by Confluence on Dec 03, 2008 15:16