Is there a way to conditionally supress a macro's results? {Content by Label} macro returns "No content found for label(s) x."

Ken Trough March 21, 2013

I was trying to use the {content by label} to build tables of contents.

Basically I want to maintain a "master list" of all customers with each customer having their own page (and children). I want to then build smaller lists of customers based on what level of service they subscribe to. So I could have Company X that is labeled "customer" "LEVEL2" and "x". I want to list this customer in the master customer list and I also want to list this customer under our "Level 2 Customer List". I want the lists to dynamically be built based on current pages that match the criteria. That way we can edit the customer data, add or remove labels based on changes in their service level, and the contents lists would automagically be updated with the new page labeling.

The problem with this plan is that if I have no matching results to display (no Level 2 customers that begin with the letter "Q" for instance), I get an unattractive "No content found for label(s) q" result. I would like to conditionally suppress any blank results but I haven't found a way to accomplish that.

Any ideas? Is there a better way to build dynamic indexes with conditional blank space supression within confluence?

1 answer

1 accepted

2 votes
Answer accepted
GuilhermeA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2013

Hey Ken,

Please correct me if I'm wrong, but you want to suppress if the message is "No labels found" and show if there is labels. Right? This would confuse some users, if they are using it, BUT, if you want to use it for you, and know that it would be shown as you want, then I've written a custom User Macro just for you :)

  1. Name
  2. Title
  3. Rendered
  4. And the Code
    ## @noparams
    ## This sets the variable to see if it contains a word
    #set ($bodyContent = $body)
    
    ## Then checks if it has no labels, and it does a custom message, or could be empty :)
    #if ($bodyContent.contains("No content found for label(s)"))
    There is no Cookie for you
    #else
    $body
    #end

Hope this is what you wished for, if not let me know and I can try to tweak it more!

Cheers,

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events