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

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

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

377 views 20 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you