How can I limit the include page macro to the current space?

We currently have our product releases in their own space with their own inclusion library. After releasing a new version of a product we copy the space with it's own inclusion library to create the next set of documentation for the new release. When one of our employees goes to include a specific page using the include macro the search feature is finding multiple identically named pages for the old inclusion libraries in the now old spaces.

I've tried creating a macro that wraps the include macro but the only option to search for a page is the confluence-content type and that does not have an option to limit the space to just @self.

1 answer

0 vote

it's not exactly what you're after, but you can type in the spacekey first. Also note that if you hover over the page, the link tip can help.

Are you open to build a new plugin/macro? If so you could achieve it by limiting the js search by space.

I've seen the instructions to include the spacekey, but when you add the spacekey the js search stops working. Requiring our users to know the exact title of the page they want to include really slows down their workflow.

I am totally fine creating a plugin or macro but I was unable to find a way to limit the js search by a space. Could you point me in the right direction on how to do that?

Browse to a spaces' blogs, and start searching. you'll notice that the javascript for that is limited to the blogposts in this space. The file that controls this is

./confluence-project/confluence-core/confluence-webapp/src/main/webapp/includes/js/contentnamesearch.js

In that file is the code snippet for the javascript you're after:

if (spaceBlogSearchQuery.length && confluenceSpaceKey.length) {
        spaceBlogSearchQuery.quicksearch("/json/contentnamesearch.action?type=blogpost&spaceKey=" + 
                AJS("i").html(confluenceSpaceKey.attr("content")).text(), null, {
            dropdownPlacement : quickNavPlacement(spaceBlogSearchQuery)
        });
    }

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 Friday 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...

287 views 11 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