TOC macro: exclude header that is a placeholder

Adriel Liew February 23, 2022

I currently have a placeholder text "Add more" for a header and I would like to exclude it if the user does not fill it in. I've tried inputting Add.* under exclude header but it doesn't work. "Add more" still shows as a header in the TOC.

1 answer

1 accepted

0 votes
Answer accepted
David Bakkers
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.
February 24, 2022

Hello @Adriel Liew 

I've just tested the Exclude Headings filter Add.* with the TOC macro, and it is working fine on Confluence Cloud:

Annotation 2022-02-25 103001.png

Chances are you have some other issue that is interfering. Double check the other settings for the TOC macro.

Adriel Liew February 24, 2022

Hi @David Bakkers 

Strange, I tried doing it on a blank template and the placeholder text headings still show.

template.pngpreview.png

David Bakkers
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.
February 24, 2022

Are you saying the macro doesn't work properly when looking at a template or a page created from that template?

In the lower picture, the text headings "Add more H2" and "Add more H1" have suddenly disappeared from the page... yet the TOC macro is generating a list of headings as if they were still there! That is just plain bizarre!

I have also tested the TOC macro in a template, with and without the heading filter, and then looked at that template and it correctly filtered out all headings that started with "Add":

Annotation 2022-02-25 180030.png

The TOC macros in pages based on that template work just fine too:

Annotation 2022-02-25 181615.png

I think you have some sort of content caching issue with your web browser, as the macro seems to be 'lagging' behind what is actually on the page. Try another browser for that same page and see if the macro there also doesn't correctly filter out the headings that start with "Add".

Adriel Liew February 24, 2022

Wait let's go back to my story.

I'm creating a template with some text headings and placeholder headings.

When the users use the template to create a new page, assuming they fill in the placeholder text headings with "xxx" if it's applicable, and leave them blank when it's not, I want the page's TOC to show the headers that are filled and those blank (still placeholders) to be excluded.

Hopefully this makes sense.

and yes I do think that that is bizarre that the TOC is showing the placeholder headings.

and yes I tried using Edge browser and it's happening there too.

David Bakkers
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.
February 24, 2022

Sorry, but I'm out of ideas, as all the combinations I've tested all work perfectly and I have no idea why the same would not work for you, nor how the TOC macro is generating a list of headings when they aren't even on the page.

There are more strange things on the template / page screen grab you've supplied:

  1. The first line "H1", which I assume is the style Heading1, has black text, but the third line "Add more H1", which I assume is also the style Heading1, is grey.
  2. The second line "Add more H2", which I assume is the style Heading2, is grey text, but the fourth line "H2", which I assume is also the style Heading2, is black.

I have no idea why lines of text that are formatted with the same heading style are changing colour.

If you are in a corporate environment, maybe someone might have changed the default style and it's damaged how it interacts with the TOC macros?

Do all the usual testing, such as a web browser outside your corporate LAN to eliminate proxy / firewall caching issues. Get others to test via their web browsers. Get another developer to double check your work etc.

Other than that, you've got a very funky problem that you will need deeper investigation with your ITS department and even Atlassian to unravel

Adriel Liew February 24, 2022

There are more strange things on the template:

  1. The first line "H1", which I assume is the style Heading1, has black text, but the third line "Add more H1", which I assume is also the style Heading1, is grey.
  2. The second line "Add more H2", which I assume is the style Heading2, is grey text, but the fourth line "H2", which I assume is also the style Heading2, is black.

I have no idea why lines of text that are formatted with the same style are changing colour.

Wait isn't that normal? I'm using the placeholder text. Here's a GIF on what I did:

placeholder.gif

David Bakkers
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.
February 25, 2022

Ahhh, OK, now it makes sense. When you use the words 'placeholder' or 'placeholder text' you don't mean the normal English language meaning of those words, you mean you're using the Placeholder text MACRO.

Yes, that is the expected behaviour. The Placeholder text macro will display no text on the destination page until you put a value into it. However, if that Placeholder text macro has also been styled as a Heading, the TOC macro can 'see' it. Unfortunately, in the absence of a value, it has no choice but to read the hidden, temporary value of the Placeholder text macro and put that into the table. It can't apply the exclusion rule on text that doesn't exist yet.

The only way to avoid this is to not use the Placeholder Text macro, but just put plain old text on the template page, style it as a Heading and start it with the text "Add more", then hope your users are smart enough to work it out. When I want this sort of traditional 'placeholder' text on a page that I want a user to change, I put that text inside square or curly brackets, to make it fairly obvious to the user to change it to the real value.

I suggest you then search through the Confluence Cloud Feature Requests to see if someone else has already noted that limitation of the TOC macro when used with the Placeholder text macro to see if it's already raised as a bug or feature request.

Adriel Liew February 25, 2022

Ah OK I see!

I was assuming my users to not be as smart as I think they are so I wanted to use the placeholder text macro. I guess not being able to use the placeholder text macro as a heading is kind of a "limitation" for the TOC macro then. Thank you for your help!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events