How to generate a selectable drop-down {list-data} with related labels in Confluence?
Asked by Stefan Eike:

I need a drop-down-list in my Confluence template of all labels being used in common with another label.

**Example**

I have a lot of pages about tools. One page for each tool being used in the company. Each page is labeled with the label **tool** and the name of the tool, e. g. **firefox**.

I have a template for how-tos and need a drop-down-list, where the user can select the name of the tool, to which this how-to is related to. So I want a drop-down-list of all labels, being used in common with the label **tool**.


Answers:
author: Adolfo Casari
body: I think you are mixing Reporting plugin with Scaffolding plugin. You should focus only in Reporting Plugin. I am sure you can make a report that in one column has all "*tool*" labels (i.e. pages have the tool label plus the actual label that will be displayed) and in a second column a link to all pages that have that label.

You can control the scope of the search (a specific space, a list or all of them) with filters plus a filter for the label *tool*.

This is a piece of code that list labels (Tipo Contenido), number of ocurrences (Instancias) and the pages (Paginas) with that label in a Table with 3 columns for a specific space (space key = ROBCCHSWIFT) :

```
{report-block:output=wiki}{space-reporter:space=ROBCCHSWIFT}{text-sort:space:name}{space-reporter}{report-body}{report-table}{local-reporter:space:labels in content}{text-filter:label:title\|exclude=vision,567}{text-sort:label:title}{local-reporter}{report-column:title=Tipo Contenido}*{report-info:label:title\|link=false}*{report-column}{report-column:title=Instancias\|injected=true}{report-variable:Space Content}{local-reporter:label:content}{text-sort:content:title|order=ascending}{content-filter:@self\|space=%report:parent &gt; report:item &gt; space:key%}{local-reporter}{report-variable}{report-info:variable:Space Content &gt; size}{report-column}{report-column:title=Paginas}{report-info:variable:Space Content\|link=true}{report-column}{report-table}{report-body}{report-block}
```

comments: author: Stefan Eike
body: Hi Adolfo,

this looks awesome, but it is not what I'm searching for. If found two threads containing very similar questions:

<http://community.customware.net/customware/topics/report_based_generation_of_list_options_for_list_data_macro>

<http://community.customware.net/customware/topics/combination_of_list_data_and_reporting_code_stopped_working_in_confluence_3_0>

But the result of both is, that it doesn't work that way (actually with Confluence 3.x).

Maybe a workaround is possible, like a (meta-)page, where you aggregte and store all related labels and then aggregate the content again as list-data items. But I'm not sure, if this would work, 'cause I'm very new to Confluence and I don't have much experience.


author: Stefan Eike
body: I decided to work around the problem. I have created a user macro called **tool-list**, which creates (manually) a list of tools I have. This macro can be embedded in several templates, if needed. If I get another tool, or have to remove a tool, I have to add or remove it once in the user macro. This is not as elegant than aggregating these information by labels, but works as well.


author: Stefan Eike
body: Hi Matthias,

OK, here we go, let's create a short design pattern.

First page: 'Source'

This page contains a table-data macro. You can use multiple table-data macros on the same page. To organise them, you should put them in column macros. I usually hide them in View mode with the show-if macro and place this data at the root node of my content section (e. g. 'Software', 'Terminology', etc.). I call the space 'EXAMPLE' in this snippet. The data field is just called 'Category'.

1. Create a page called 'Source' in a space.
2. Paste the following code on the 'Source' page:  

   ```
   {section}{column}{table-data:order=asc|name=Category}|| Category |||{text-data:content=wiki|name=Category|atlassian-macro-output-type=INLINE|type=line}{text-data}|{table-data}{column}{section}
   ```

3. Save the page.
4. Open the page in 'View' mode.
5. Click on 'Edit Contents'.
6. Add one or more entries.

Second page: 'Target'

This page uses a local-reporter inside of a list-data to report on your 'Source' page. The fetched data is returned as list-options. Feel free to use multiple list-datas on the same page. They will also work in live-templates.

1. Create a page called 'Target'.
2. Paste the following code on the 'Target' page:  

   ```
   || Category | {list-data:Category|required=true|multiple=true}{report-block}{local-reporter:data:Category|source=EXAMPLE:Source}{report-body:injected=true}{list-option}%data:Category%{list-option}{report-body}{report-block}{list-data} |
   ```

3. Save the page.
4. Open the page in 'View' mode.
5. Click on 'Edit Contents'.
6. Select one or more options.
7. Be happy!

comments: author: Mike Diehn
body: Stefan, it's a year on from your original post here and I'm trying this using possibly newer Confluence and maybe more recent staging and reporting plugins. All is well until step 5. When I "edit contents" there is a Category selection list but there are no options. Any ideas what I need to adjust?


author: Mike Diehn
body: Never mind. I figured it out. The word EXAMPLE in the source in local-reporter is a space key. I almost slit my wrists trying to get this to work with my space \*named\* EXAMPLE - it's space key is "EX" Arggghhh!!!


author: CharlesH
body: One possible approach here would be to use the Reporting plugin (from CustomWare) and analyse the labels in use in your space describing the tools. The Space Supplier is able to provide a list of labels used within the space.

More details here: <http://wiki.customware.net/repository/display/AtlassianPlugins/Space+Supplier>

The example in this case produces a list of labels used across the entire Confluence instance, but you could use local-reporter to limit this to the current space only. Additional filters could be added to limit the analysis further if required.

The labels will be returned as a list. It should be possible to use this in the construction of your drop-down list, so each element in the returned list generates a list element for your drop-down list.

Regards,

Charles

comments: author: Stefan Eike
body: Hi Charles, thanks for your answer. I'm currently stumbling about the problem how to nest my report-info in list-options. This throws a lot of exceptions.

```
{list-data:my-tool-type|type=select|multiple=false|required=true}{report-block}    {content-reporter:label=tool}        {text-sort:label:title}    {content-reporter}    {report-body}        {list-option}            {report-info:title}        {list-option}    {report-body}{report-block}{list-data}
```


author: Wes Tracy
body: Stefan,

Have you thought about using the Expanding macro in the macros list? You could put a link to each tools page inside the box so, when the user clicks to expand the box, they can select the page they want to jump to.

Wes


author: Stefan Eike
body: Sorry Matthias, maybe the [Run Macro](https://marketplace.atlassian.com/plugins/org.swift.confluence.run) is more useful and cheaper for your, but I did not use it so far. Scaffolding and Reporting are very powerful macros. Hundreds of our Confluence pages use these macros. With them you can create typified data, queries, useful reports, dynamic data and stuff like that.

To be honest: Think twice before installing a plug-in. And never trust a free plug-in!!! I used many plug-ins, which were free. And after a few months I had to tell my boss, that I need a few hundred bucks to pay for Confluence macros. OMG!

Good example: table-plus. Sortable tables in Confluence. This was a free plug-in, we use it on hundreds of pages. It became commercial, now it costs 200 $ and 100 $ renewal.


author: Matthias Brabetz
body: Hi Stefan,

many thanks for the fast reply!

This solution appears amazing, indeed. Anyway, we need to evaluate if it's worth the money as we haven't purchased either the Scaffolding Plugin, nor the Reporting Plugin, so far. 800 bucks for both are quite a lot...

Are you aware of another cost neutral solution?

Thanks and all the best,

Matthias


author: Matthias Brabetz
body: Hi Stefan,

I'm looking exactly for the solution you're describing. Is the "tool-list" user macro working and available? I cannot find it anywhere...

Many thanks in advance!


author: Stefan Eike
body: It would be also nice, if someone would tell me, that it isn't possible to do that, if that should be the case. :)


Tags: label

list

select-list

template