Applying Labels via Blueprint
A user's selection from a picklist of options will be applied as a label to the page created from a Blueprint.
Now you can add labels to a page during Blueprint creation. In the Blueprint Wizard, users can select from a picklist of options. Their choice will be applied to the page as a label. This requires a small amount of additional configuration in the JSON Definition file, but it's worth the effort!
Create your Page Blueprint
Learn about creating a Page Blueprint. If you'd like to show the label names, as text, on the page itself, then use a substitution field in the place where you want your user's picklist selection to be presented. The label text will be displayed wherever this substitution field is placed, in addition to applying a Confluence label to the page.
Access your Blueprint JSON Definition
Read more about Accessing and Editing the JSON File.
Set the "type" to "list", and add the "values" attribute to the blueprintField object
Add a new line to your Blueprint Field object definition, as seen in the code snippet below. The values for the "values" attribute will be the options displayed to the user. This is an array of items in quotations. The items must conform to Confluence label requirements, namely: all lowercase and with no special characters except hyphens and underscores. Invalid labels will result in an error message.
"blueprintFields" : [ { "id" : "content-type", "name" : "Content Type", "type" : "list", "required" : true, "helpText" : "Select a content type from the list. It will apply a label to the page.", "values" : [ "article", "memo", "policy", "profile_page", "tpps_report"], "addLabels" : true }, ... ]
Add the "addLabels" attributes and set it to true
To apply the selected item as a label on the page, set the "addLabels" attribute to true
.
Optionally: add "multiselect" and set it to true
To allow users to select more than one value, set the "multiselect" attribute in the JSON to true
. Doing so with the addLabels attribute set to true
will result in all of the selections being added as labels to the page. Note that if the substitution field is on the page (and these are intended to display), multiple selections will be presented in a comma-separated sequence.
Re-Upload your JSON to the Blueprint Definition Page
That's It!
Test your Blueprint by creating a page from it. The options shown should be those defined in the "values" array (in our example: "article", "memo", etc.). The selected option should display on your page wherever its substitution field was placed. Additionally, the selected option will be applied as a label to the page.
Got Targeted Search? Want to use Search Filters instead of these manually defined values? Check out Using Targeted Search Filters in a Blueprint Maker Blueprint!