Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Create title for blueprint index page dynamically

Alex Yasurek
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 4, 2014

Hi,

I was wondering if there is a way to give the index page that gets created with a blueprint a title thats cerated dynamically. I want to create the title based on information the user enters in the wizard. I know how to do it for the actual blueprint page by using:

protected BlueprintContext updateBlueprintContext(BlueprintContext blueprintContext){

String pageTitle = "Some title";

blueprintContext.setTitle(pageTitle);

return blueprintContext;

}

How would I do something similar for the actual index page? This would also only occur the first time a blueprint is used in a space since that is the only time the index page is created. After that only the actual blueprint is is added to the space so I wouldn't need to change the name of the title.

3 answers

1 accepted

1 vote
Answer accepted
Sid Sethi August 6, 2014

Okay. Let's do this. Use the BlueprintListener class to call the onBlueprintCreateEvent. And add the following code to the onBlueprintCreateEvent method.

@EventListener
public void onBlueprintPageCreateEvent(BlueprintPageCreateEvent event)
{

Map<String,Object> blueprintContext = event.getContext();

String indexPageName = blueprintContext.get("IndexPage").toString();

Page page = event.getPage();

Page parentPage = page.getParent();

parentPage.setTitle(indexPageName);

}

Create an input box inside the wizard form with name and id "IndexPage". So when the blueprint is created, the Listener class will get whatever you input inside the IndexPage box, and set the title of the index page which is also the parent page of your blueprint. But the only catch here is, you'll have to figure out how to differentiate b/w the index page and a generic parent page. Perhaps you could parameterize the index page. Like everytime the index page is generated, it will have a constant name. So you can check if let's say the index page is always created by the name, "My Index", put a check that would see if the title of the parentPage is "My Index" then only set the title of the page. Else just ignore and don't do anything. Hope you get an idea of what I'm trying to say. Good luck :)

Alex Yasurek
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 6, 2014

I think I understand what you are saying and will give it a shot. Thanks a lot for your help in this.

0 votes
Sid Sethi August 6, 2014
&lt;blueprint key="example" index-key="example" content-template-key="actual-template" index-template-key="my-index-page" &gt;

&lt;/blueprint&gt;

&lt;content-template key="actual-template"&gt;
&lt;resource name="template" type="download" location="/xml/actualTemplate.xml" /&gt;
&lt;/content-template&gt;
&lt;content-template key="my-index-page"&gt;
&lt;resource name="template" type="download" location="/xml/myIndex.xml" /&gt;
&lt;/content-template&gt;

You can use this to create your own index page if you want.

Alex Yasurek
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 6, 2014

I am already creating my own index page but I just don't know how to give it a title dynamically from a java file. My blueprint has a form and then based on what the user puts in, creates a blueprint page with that info. I am able to dynamically create a title for the blueprint page in the java file but not the index page.

0 votes
Sid Sethi August 6, 2014

The index page I believe is only created when you create the page outside the parent page, lets say on the Dashboard. Might be a good idea to create the page you're trying to create on top of an existing page. That ways, the index page is never created. Else Confluence will pick up the name of the blueprint and create your page under it.

Sid Sethi August 6, 2014

From the Dashboard I meant that Confluence does not know the parent page of the blueprint you're creating.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events