Thursday, March 8, 2012

Show the Content ID of a Page

The following instructions are based on Jeremy Largman's instructions. To view the content ID of a page, complete the following procedures. NOTE: you must be a Confluence admin to add a new user macro.
  1. Go to Browse > Confluence Admin > User Macros.
  2. The Create a User Macro section opens.
  3. Press the Create a User Macro button.
  4. Enter a name in the Macro Name text field. (Something like "pageid.")
  5. Enter a title in the Macro Title text field.
  6. Under the Definition of User Macro section, verify that the No macro body radio button is selected.
  7. Select HTML from the Output Format dropdown.
  8. Enter the following in the Template text box.
    $content.getIdAsString() 






















  9. Press the Save button.
  10. Edit a Confluence page.
  11. In the area you wish to see the page ID, type:
    {<macro_name>}
    For example: {pageid}

Page Unavailable, Can't Edit or Delete

This week I selected a page link in Confluence and received a server error. I could not view, edit or delete the page. I thought if I knew the page ID, I might be able to enter the appropriate edit URL. But I didn't know the page ID.

I looked around on the Internet and found Jeremy Largman's user macro, but I couldn't edit the page to add the macro. Finally, I found the correct procedures from Atlassian: Editing or Deleting a Page That Won't Render.

Page ID
Ultimately, I had to ask our admin to retrieve the page ID from the database. He was able to do so by running the following command against the database:
select contentid from CONTENT where title = '<page_name>' and version = '1';

Edit URL
Once I had the page ID, I entered a URL similar to the following in my browser's address bar:
http:///pages/editpage.action?pageId=<page_ID>
Other edit options include pressing the Ctrl + e keys or accessing the edit URL that includes the page name. For example:
http:///pages/editpage.action?spaceKey=<space_key>&title=<page_name>

Delete URL
To delete the page, try:
http://<base_url>/pages/removepage.action?pageId=<page_ID>

Other Commands

Here are some other commands that may be useful.

Edit blog post:
http://<base_url>/pages/editblogpost.action?pageId=<page_ID>
 
View attachment:
http://<base_url>/pages/viewpageattachments.action?pageId=<page_ID>
 
Delete attachment:
http://<base_url>/pages/removeattachment.action?pageId=32787&fileName=harbour.jpg&version=1
 
Retrieve wiki markup from database:
select body from bodycontent where contentid in (select contentid from CONTENT where title = '<page_name>');