Is there a macro to show content with no labels?
Asked by Ste Griffiths:

Hi all,

I know about the Content by Label macro, but now I want to highlight (on the front page of our Confluence Knowledge Base) any pages which do not have **any** labels applied. This is to encourage users to go back and classify pages to make them more discoverable.

Is there a feature or a workaround to do this?

Cheers,  
Ste


Answers:
author: Boris MBOUMEHANG
body: Hi Ste,

I think this could be done by using Confluence REST API. In fact, you can write a script performing the following actions:

* Browse all the content of your Knowledge Base and getting the labels for each page. This could be a combination of:
  * Browsing all spaces and getting the content of each one:  

    <https://your-domain.atlassian.net/wiki/rest/api/space>  
    <https://your-domain.atlassian.net/wiki/rest/api/space/{spaceKey}/content>
  * For each content retrieved, get its labels:  

    <https://your-domain.atlassian.net/wiki/rest/api/content/{id}/label>
* Put the result you got on the front page of your Knowledge Base:  

  ```
  curl --request PUT \  --url 'https://your-domain.atlassian.net/wiki/rest/api/content/{id-for-KB_frontPage}' \  --user 'email@example.com:' \  --header 'Accept: application/json' \  --header 'Content-Type: application/json' \  --data '{  "version": {    "number": 19  },  "title": "",  "type": "page",  "status": "current",  "ancestors": [    {      "id": ""    }  ],  "body": {    "view": {      "value": "",      "representation": "view"    },    "export_view": {      "value": "",      "representation": "view"    },    "styled_view": {      "value": "",      "representation": "view"    },    "storage": {      "value": "",      "representation": "view"    },    "editor2": {      "value": "",      "representation": "view"    },    "anonymous_export_view": {      "value": "",      "representation": "view"    }  }}'
  ```

  Extract of [Confluence REST API page](https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-put)

Hope it will help you.

Regards,

Boris

comments: author: Ste Griffiths
body: Thanks for the work you put into this answer Boris. I think it's a little more heavy duty than I was looking for. Maybe one day there will be a macro to support this :)

Thanks again.


author: Boris MBOUMEHANG
body: You are welcome Ste :)  
I also hope that a macro will support this


author: Victor Mutambuki
body: Ste,

Maybe have your users look into their Activity Stream and check for labels in their recent works. [Activity Stream](https://confluence.atlassian.com/doc/activity-stream-gadget-218275789.html).

Also, for pages that are created in the same way, form and collect the same data, you can have a template, add labels to it, then having users create pages from [templates](https://confluence.atlassian.com/doc/page-templates-296093785.html).

Victor

comments: author: Ste Griffiths
body: Thanks for your answer Victor :)


author: Rab Tait
body: I have a content management space that uses labels and templates, and buttons to add content based on the template. All templates include a zzzuncat label by default. When people add new content, they are supposed to label it from a small set of available labels and remove the zzzuncat label. I have an admin page where I have a search for pages with the zzzuncat to see if people have forgotten to label what's been added.

This works but is not without issue. I'm starting with an empty Content space, so I know that all content will be added using my templates. I also have a small number of users and a fairly small label set. For larger projects, it is probably not viable. I also can't cater for instances where people just remove zzzuncat and don't add other labels. But, as I've said, I have a small number of users who I know.

Using this has allows us to have a usable CMS in Confluence with content reuse and single source of content.


Tags: cloud

confluence-cloud

macro