Page location with API

Hi, is it possible to get this screen to choose the page location with Confluence API?

Thanks.

2 answers

1 accepted

2 votes
David Simpson Community Champion Jun 04, 2013

You need to look in the Confluence source code. If you haven't got it, spend 10 bucks to get a starter license.

The file you're looking for is page-move-dialog.js It has all you need to get going.

Here's where the business is to trigger it:

$("#action-move-page-dialog-link").click(function (e) {
        e.preventDefault();

        if ($("#move-page-dialog").length > 0) {
            $("#move-page-dialog, body > .shadow, body > .aui-blanket").remove();
        }

        new Confluence.MovePageDialog({
            moveHandler: viewPageMoveHandler
        });

        return false;
    });

Swap out the link click to be however you're triggering the screen.

2 votes
David Simpson Community Champion Jun 02, 2013

Are you trying to do this remotely using web services or from within a plugin?

Remotely:

I normally take a look at the Confluence CLI in Atlassian CLI. If it's possible there, then, there's likely a SOAP API available.

To move a page under a new parent using Confluence CLI...

confluence --action movePage --space "zconfluencecli" --title "This Page Title" --parent "New Parent Page Title"

More CLI examples here

So, it's entirely possible using the Confluence remote APIs.

For more details check the movePage method on https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods#RemoteConfluenceMethods-Pages

  • void movePage(String token, String sourcePageId, String targetPageId, String position)- moves a page's position in the hierarchy.
    • sourcePageId - the id of the page to be moved.
    • targetPageId - the id of the page that is relative to the sourcePageId page being moved.
    • position - "above", "below", or "append". (Note that the terms 'above' and 'below' refer to the relative vertical position of the pages in the page tree.)

As a standard plugin:

Try something like this...

Page page = pageManager.getPage(spaceKey, pageTitle);
Page newParent = pageManager.getPage(parentSpaceKey, parentPageTitle);
page.setParentPage(newParent);

Hi thanks for your answer, it's with a plugin but i now how to set a parent with the API, i just want to know if it's possible to get this screen in my plugin to let users choose a space and parent like we can do in confluence.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

763 views 23 12
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