[CONF] Is there a way to find out if the content by label macro will not find any pages before rendering?

I use the contentbylabel macro in a template to pull in lists of related pages based on labels. However, sometimes there are no related pages and I would like to know if there's some Velocity code I could use where if results = 0 I can put "N/A" or just not make it show at all.

The default Confluence behaviour of printing out "No content found for label(s) YOURLABELSHERE." is unattractive.

Thank you.

1 answer

1 accepted

This widget could not be displayed.

One possiblity is to hide the text using CSS.

Something like:

#main-content .tableview {
 visibility:hidden;
}

However, this might have unintended consequences if you have any other content which matches that class.

Cheers,
Mark

Thanks for the suggestion but the tableview class is present regardless of whether there is content found or not. It really needs to be something I can get Confluence to run on when a condition is true or false.

That does seem to be the case, sorry about that.

I found another couple of suggestions which might work for you:

  1. Edit the i18n label for the macro
  2. Create a user macro to override the text on a page

Hope that helps more than my first suggestion :)

Mark

Great!

There is also an open request to improve the experience in the macro itself, which you can vote on.

Thanks, Mark. The JS solution works. Would have preferred something in VTL but this is fine.

Cheers!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

115 views 2 0
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