How can I get the page's id by the title?

yao lei August 20, 2011

hello,all

I can get the title of a page,now,I want to get the page's Id by the title

How can I do that ?

thanks for reading and help.

lei

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Betsy Walker
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.
August 21, 2011

I'm not sure if you're asking for how to get it via a plugin, or just in general. This user macro will allow you to get it by using the page-info macro.

## ----------------------------------------------------                                                                                           
## Macro title: pageid_edit
## Macro has a body: No
## Body processing: Use unprocessed macro body
## Output: Generates Wiki Markup
##
## This macro displays a View Page and Edit Page link
## for the space/page you specify. (These URL forms require
## a pageid, so this macro determines the pageid from the space/page.)
## Useful when a page won't display, or when you need to view or edit
## a large volume of pages (such as when you have a list of pages in
## a text file or Excel spreadsheet).
##
## Params:
## space: the space key
## page: the page title
## ----------------------------------------------------
#set ($wikibaseurl = "$action.getGlobalSettings().getBaseUrl()")

#if ($paramspace)
#set ($spacekey=${paramspace})
#end
#if ($parampage)
#set ($page=${parampage})
#end

#set ($pageid="{page-info:pageId|page=$spacekey:$page}")

[View $spacekey:$page|$wikibaseurl/pages/viewpage.action?pageId=$pageid] [Edit $spacekey:$page|$wikibaseurl/pages/editpage.action?pageId=$pageid]
1 vote
Colin Goudie
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.
August 20, 2011

Do you know what Space the page is in?

You can get the Page object via the pageManager with

getPage(String spaceKey, String pageTitle);

Then you can get the Id from the Page object

TAGS
AUG Leaders

Atlassian Community Events