I wonder if there is a macro or some other method to display some of a page's labels and exclude others. For example, if a page has labels book, drama, and historical, I only want to display drama and historical since it's already clear from context that this is a book.
I have been using the Page Info macro to list labels, and sometimes the Report Info macro from ServiceRocket's Reporting plugin. Neither one has an option to list some labels but not others.
Hi @Michelle Rau good ,
There is no macro available out of the box to achieve what you are asking for, however, this can be done with a User Macro.
I have create the below one as an example and it works fine on my test instance.
## Macro title: page-labels-not-in-list
## Macro has a body: N
## Developed by: Dario
## Date created: 7/11/2019
## Installed by: Dario
## @param Label:title=Label|type=string|required=true|desc=List of labels comma separated
#set($labelList = $paramLabel.split(","))
<h2>List all labels for the page, excluding: $paramLabel </h2>
<br />
<span>
#foreach($pageLabel in $content.getLabels())
#set($found = 0)
#foreach ($label in $labelList)
#if($pageLabel == $label)
#set($found=1)
#end
#end
#if($found == 0)
<span class="aui-label">$pageLabel</span>
#end
#end
</span>
Can you kindly test it and confirm it works for you as well?
Cheers,
Dario
Oooh! I will ask our wiki admins if we can test this.
In the meantime, can you paste a snapshot of what this looks like on a page? That will help me describe to them what it does.
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Michelle Rau good ,
Please notice that I just provided a very easy example of a user macro that prints all the labels from the current page, excluding the ones provided in input.
As it is, the macro is just writing a line of text followed by the list of labels (excluding the ones configured as the input for the macro):
You will have to extend and modify the according to your needs.
You can also modify the way this looks by using JavaScript and CSS. See below documentation for details on how to do so:
Cheers,
Dario
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.