confluence unexpanding expand macro when referenced with an anchor

Paul DeSousa
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 4, 2015

Hi all,

Is there anyway to reference a page that has a large set of expand macros to where the reference would expand only the given macro that was referenced?

Thanks,

Robert

 

3 answers

1 accepted

4 votes
Answer accepted
Stephen Deutsch
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 4, 2015

Hi Robert,

You can include this user macro in all pages in a space (or just include the javascript in all pages using the Custom HTML area) and it will automatically expand only the area where the anchor is embedded:

https://bitbucket.org/stephendeutsch/confluence-user-macros/src/bb28804121a99ccd01b95d0ebed4097468d0244d/anchor_in_expand/anchor_in_expand_macro.vm?at=master

However, are you also wanting it to close any other expanded expand macros? It doesn't do that (yet).

Paul DeSousa
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 4, 2015

Very cool! How do you reference it though as it is does not have a title?

Paul DeSousa
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 4, 2015

Never mind I figured it out. Love it. Wish I could up-vote it twice :-)

Stephen Deutsch
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 4, 2015

Glad you like it :) As a bonus, it also converts regular anchor links (i.e. #anchor) to Confluence style anchor links automatically (i.e. #PAGETITLE-anchor)

Niclas Ries October 22, 2018

Hi Stephen,

thanks for that useful macro! I wonder if there is any way to jump into the expander via the anchors and scroll up to the headline which is written above the expander?

Thank you in advance!  

0 votes
Rob Powers November 27, 2017

I'm also trying to use this code. I added it to an HTML macro at the top of the wiki page, but that didn't work. Next, I added it to the footer of the space layout. Both attempts failed. What am I not understanding here?

Stephen Deutsch
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.
November 28, 2017

Hi Rob,

This is actually an older version of the code that I have not updated. Could you try the code from here:

https://jira.atlassian.com/browse/CONFSERVER-27357?focusedCommentId=673236&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-673236

and see if that makes any difference?

Rob Powers November 28, 2017

Thanks for your help, I probably don't have sufficient privileges to activate this code. I'm getting the following error  "Error rendering macro 'html' : Security restricted macro is not allowed. An edit restriction includes an unauthorized entry: username@email.com".

Rob Powers December 5, 2017

@Stephen Deutsch - your macro works, now I just need to decide where to insert it - @ the page, space, or wiki level. The low-tech solution would be to separate the collapsed sections into child pages, but that's not so great from a UX perspective.

0 votes
Teri Warner April 24, 2015

I'm trying to use the code and must be missing something. I added the code in an html macro onto the page that has the expand macro (before the macros). I placed the anchor within the expand macro. However, when I click on the link to the expand macro page, nothing expanded. What am I missing?

Robert Nadon
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.
September 17, 2015

Are both your anchor-expand macro and anchor inside the expand macro?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events