It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Include Page Macro: Is there a known issue using markup within a custom User Macro? Edited

Hi community, I'm running into a really annoying issue with the "Include Page" macro within a User Macro.


We have a large team, and many people have different permissions to different content, including a few reference pages for anonymous users in the larger organisation. If the user doesn't have access to the page being referenced by an Include macro, the error message looks a bit ugly, so we want to provide some better content instead. Hence we have written a User Macro that outputs the Include Page macro if the user does have access, otherwise we output an HTML block.


The 'include' macro works fine on its own, but if I create it with markup using a custom User Macro, it doesn't load the referenced page, it loads the current page within itself.

Example: I have two pages: CurrentPage and LookupPage:

1. I can add the Include Page macro on my page, 'CurrentPage'

{include:mySpace:LookupPage|nopanel = true}

 As expected, this renders correctly:

{CurrentPage Content}
- {LookupPage Content}
{Rest of CurrentPage Content}

2. If I output the macro via the User Macro:

#set($spacekey = "mySpace")
#set($pageName = "LookupPage")
#set($macro = "{include:${spacekey}:${pageName}|nopanel = true}")

#if ($permissionHelper.canViewPage($action.remoteUser, $spacekey, $pageName))
<span>some content</span>

In the Edit Macro Preview for my User Macro, I correctly see the content from LookupPage, as I should, but when I publish the page, instead of seeing LookupPage content where the macro is, I see the current page nested within itself:

{CurrentPage Content}

 -  {CurrentPage Content}
 -  (Error that CurrentPage is already referenced)
 -  {Rest of CurrentPage Content}

{Rest of CurrentPage Content}

I've tried just outputting the $macro text and feeding into the markup macro to make sure there wasn't anything dumb getting written out, but it's definitely getting calculated correctly (plus, I wouldn't see LookupPage content in the Preview if it was wrong).

Has anyone run into this issue? Is there something I'm doing wrong?

(Minor edit for clarity)

1 answer

No ideas?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,465 views 6 6
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you