I would like to make a user makro that allows me to set the options of a dropdown menu as all the pages in a space with the label "inventory" (for example).
This is my code to set the options to the parents of the labels:
## @param Option:title=Label|type=string|required=true|desc=Pages that contain this label should be displayed.
#foreach ($paramOption)
#if ($label.name == $paramOption)
#set ($options = contentLink2($Label.name)
#end
#end
Doesn't work however...
Can anyone help please?
If I understand correctly, you are wanting to populate the pull-down menu in your macro to a list of labels on that page? If so, it can't be done.
What is the variable $options?
Also your Option param is a string, not an array. You would need to have the user enter a list of labels (maybe comma separated), then parse that list into an array.
No. I want to populate the list with PAGES in a space that have a specific label. ONE label that applies to a few pages. So that I can choose which of the pages should be "linked" to the current page.
$options would be the "lines" of the dropdown. The options that you can choose from.
Ideally I would like to have the user to NOT interfere with the content of the dropdown. The user should ony be able to create the page (ignore the dropdown in the process of creating the page) and when the page is created, the user should be able to choose from the preset (by me) options in the dropdown.
Edit:
To give you an overview of the practical application that I imagined:
I am currently creating two template pages. One to create an entry about an employee and one to create an entry about an inventory item. In the employee-page, the user should be able to choose which inventory-page should be linked to the employee. I know this can be done by an internal link to that page, but I do not trust the users to know this sort of stuff. Thus I want to give them options to chose from.
If there are better ways than a dropdown then please give suggestions. I am relatively new to the world of Confluence.
Edit2: spelling
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe you can take a look at the ScriptRunner add-on and more specifically the "Choose Label macro" .
It will enable you to make a drop down list of labels that can be selected. I use that in a template page so I know that the users can select one or more labels that will be added to the page that is created with the template. It even allows me to show readable text in the drop downs that will be translated into the corresponding label(s) in the labeling format we defined. This will prevent users from entering the wrong label.
I use the page labels to create overviews and dashboards that will show all pages using the " Content by label " macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The labels for the pages are automatically set by scriptrunner's "Add Label" macro.
I want to have two templates. Template A is a description of employees and template B is a description of inventory items.
All pages A get the label "user" set and all pages B get the label "item". This is always like that.
Now I want to be able to link page/s B to a page A by setting a dropdown menu to show all pages with the label "item" in page A. The person that creates the page from my template should be able to choose from the dropdown list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In that case, indeed, the Scriptrunner choose label macro is not usable. What you want is to have a dynamically created list in the drop down of all pages that have a certain label. These kind of dynamic real-time content is not possible with the standard Confluence system.
It is easy to show a list of all pages with a certain label but to create a drop down showing pages with a certain label may require an add-on or make your own macro. I suggest you to either look into forms add-ons or database add-ons.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.