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

How do I set titles to pages in a space blueprint?

Niko Mäkinen January 20, 2014

I have created a space blueprint using this tutorial and modified it slightly in the process. In addition to the home page of the space it has now a child page defined in atlassian-plugin.xml.

Everything works fine except the setting the title of the pages. The home page of the space gets the correct title ("Space title frontpage") but the child page is titled "Space title frontpage - Child page name" when it should be titled "Child page name". The space frontpage title is set in the JavaScript as in the tutorial.

How do I name the pages separately? Is this even possible? Does the page hierarchy definition have something to do with this?

Page hierarchy definition in atlassian-plugin.xml:

<content-template ref="space-homepage-template">
  <content-template ref="space-child-page-template"/>
</content-template>

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

11 votes
Answer accepted
Robert Reiner _smartics_
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.
February 1, 2014

I'm new to plugin programming, so I don't know, what the best way of doing this is. I know of two options.

1. Add a hidden input element named 'noPageTitlePrefix' to your soy template.

{template .createSpaceForm}
<form action="#" method="post" id="create-space-form" class="common-space-form aui">
    {call Confluence.Templates.Blueprints.CreateSpace.createSpaceFormFields}
        {param showSpacePermission: false /}
        {param fieldErrors: $fieldErrors /}
        {param name: $name /}
        {param key: $key /}
    {/call}
    <input type="hidden" name="noPageTitlePrefix" value="true" />
    <input type="hidden" name="atl_token" value="{$atlToken}" />
</form>
{/template}

2. Override com.atlassian.confluence.plugins.createcontent.api.contextproviders.AbstractBlueprintContextProvider and add to updateBlueprintContext:

// Workaround to get the page not prefixed by the parent pages.
blueprintContext.put("ParentPageTitle", "");

Niko Mäkinen February 2, 2014

Thank you Robert! :)

Just added the magic input tags to the soy template and voilá.. works like a charm!

Actually you helped me to figure out another problem as well. Jumping from Confluence version 5.3 to version 5.4 prompted an error concerning atl_token. Just had to add that other input field as well to the template.

Awesome!

BTW. Is this documented somewhere or how have you come across this?

Alex Bird March 2, 2015

I found option 1 worked perfectly for me. Thanks!

Ivan Fernandes August 26, 2016

Works perfect for me too!!

Thank you!!

1 vote
Robert Reiner _smartics_
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.
June 19, 2014

Hi Stacia,

I'm extending com.atlassian.confluence.plugins.createcontent.api.contextproviders.AbstractBlueprintContextProvider and set the title to the blueprint context (as the doc you reference show):

@Override
protected BlueprintContext updateBlueprintContext(
    final BlueprintContext blueprintContext)
{
  blueprintContext.setTitle(name);
  return blueprintContext;
}

This is in my atlassian-plugin.xml:

<content-template
    key="my-template"
    ...>
    <context-provider class="com.example.MyContextProvider" />
  </content-template>

  <blueprint
     ...
    create-result="view">

Hope this helps ...

Robert

Stacia Parfionov June 20, 2014

I couldn't fit all of my reply in one comment...so here's the rest.

However, I get the following error:

Compilation failure
C:\Eclipse-projects\newsarticle2\src\main\java\com\plugins\confluence\newsarticle2\MyContextProvider.java:[10, 28] cannot find symbol
symbol: variable name
location: class com.plugins.confluence.newsarticle2.MyContextProvider

I have a little Java knowledge, but not much. I'm guessing the complaint is b/c the name variable hasn't been initialized. But when I tried to initialize it, it still didn't work.

Do you have any insights? THANK YOU so much, in advance, if you're able to help!!!

Also, I'm using a soy file for a wizard. My intent was to have it request an input from the user, which would populate the page title. However, maybe I should omit the soy file? If I do omit the soy file and use your method, what value is being placed in the page title when the editor is created? (And/or where is that value coming from?)

For reference, here's my soy file:

{namespace MyPlugin.Blueprints.newsarticle2}
/**
*  This is a news article2 wizard.
*/
{template .page1Form}
    <form action="#" method="post" class="aui">
	    <fieldset>
		<div class="field-group">
            <label for="newsarticle-content-template-title">Article title</label>
            <input id="newsarticle-content-template-title" class="text long-field" type="text" name="name"
                placeholder="{getText('article.blueprint.wizard.form.label.name.placeholder')}" maxlength="255">
            <div class="error"></div>
        </div>
		    </fieldset>
    </form>
{/template}

Stacia Parfionov June 20, 2014

Robert,

Thank you SO MUCH for your reply...unfortunately, it didn't work for me.

I updated my ContextProvider file to look like this:

package com.plugins.confluence.newsarticle2;
 
import com.atlassian.confluence.plugins.createcontent.api.contextproviders.AbstractBlueprintContextProvider;
import com.atlassian.confluence.plugins.createcontent.api.contextproviders.BlueprintContext;
 
public class MyContextProvider extends AbstractBlueprintContextProvider {
    @Override
    protected BlueprintContext updateBlueprintContext(final BlueprintContext blueprintContext)
    {
        blueprintContext.setTitle(name);
        return blueprintContext;
    }
}

And I updated my atlassian-plugin.xml file content-template to look like this:

<!-- Template for Blueprint -->
    <content-template key="newsarticle2-content-template" template-title-key="my.blueprint.title">
        <resource name="template" type="download" location="/templates/newsarticle2-content-template.xml" />  
		<context-provider class="com.plugins.confluence.newsarticle2.MyContextProvider"/>
    </content-template>

I also updated my JS file to the following (b/c I assume the JavaScript file is doing the validation of the name variable that we added to the Java file):

Confluence.Blueprint.setWizard('com.plugins.confluence.newsarticle2.newsarticle2:newsarticle2-wizard', function(wizard) {
wizard.on('submit.page1Id', function(e, state) {
        var name = state.pageData.name;
        if (myname == 'abc') {
            alert('That is not a real name!');
            return false;
        }
    });
});

1 vote
Antonio Brenlla May 27, 2014

Thanks Niko for asking. I was in the exact same situation.

And thanks Robert for the answers!

I will also keep in mind browsing BitBucket repos since there is no documentation (or I haven't found it) that explains this can of stuff.

Thanks again!

Stacia Parfionov June 18, 2014

Niko/Antonio,

Agree!!! Confluence documentation is horrible. (I hate saying that because I'm a former technical writer. Although, Atlassian's support folks have told me that they focus their efforts on writing code - not updating the documentation. So, apparently they are aware of the issue and don't think it's a concern. :-( )

Just curious - I'm trying to write a blueprint that will skip the content editor so that the page is created automatically when the user completes the information in the soy wizard. I able to get a title field to display in the soy wizard. And I can get the input from that field to populate the title field when the editor page is displayed. However, I can't get my blueprint to skip the editor page. I always still have to click "Create" at the bottom of the Editor page to create the page.

Have either of you tried this? And if so, have you had any luck with getting it to work? I posted a question here: https://answers.atlassian.com/questions/307158/instructions-to-skip-editor-by-using-a-soy-wizard-in-a-blueprint-don-t-work

I'm eager for help, so I thought I'd ask since your question is related.

Best of luck to you both, and thanks for any help you can offer,

Stacia

1 vote
Robert Reiner _smartics_
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.
February 3, 2014

Hi Niko,

thank you for your positive feedback! I'm very happy to hear that the answer has been useful to accomplish your task.

My primary resources for learning how to develop macros (although there is interesting stuff in the wiki, too) are

But IIRC it was one of the other bitbucket projects where this parameters have been used. I cannot remember which one, sorry.

Niko Mäkinen February 3, 2014

Okay!

I'm working mainly on theme/UI modifications and simple plugins (like blueprints). Sometimes finding the documentation proves to be essential in solving some development issues I've faced. The documentation I find is usually either non-existent or seriously lacking. That's why I ask for source materials.

Browsing Atlassians BitBucket repos.. yeah.. I'll keep that in mind.

Thanks again!

Robert Reiner _smartics_
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.
June 20, 2014

By chance I found the class where (at least some of) the keys are documented:

com.atlassian.confluence.plugins.createcontent.api.contextproviders.BlueprintContextKeys

Just in case it might be useful for somebody ;-) ...

0 votes
Robert Reiner _smartics_
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.
June 20, 2014

Hi Stacia,

I think you should stay with your Soy file. I let the user enter the name in the soy ("name" parameter in your example) which I use in the Provider class. I'd like to suggest you try the following:

@Override
  protected BlueprintContext updateBlueprintContext(
      final BlueprintContext blueprintContext)
  {
    final String name =
        ObjectUtils.toString(blueprintContext.get("name"), "maybe-some-default-title-here");
    blueprintContext.setTitle(name);
    return blueprintContext;
  }

(I think that the name in your soy file maps the the parameter in the blueprint context, maybe it is the id - they are always equal in my examples).

You may have a look at the "map"property (private field) of com.atlassian.confluence.plugins.createcontent.api.contextproviders.BlueprintContext in your debugger. There you'll find the keys available to your Provider class, provided via your Soy file.

The valid keys are AFAIK defined here: com.atlassian.confluence.plugins.createcontent.api.contextproviders.BlueprintContextKeys. So probably (I haven't checked this!), if your replace 'name' with 'ContentPageTitle' it may work without the Provider class? But maybe there is some other Voodoo inside ...

Hope this helps.

Robert

Stacia Parfionov June 22, 2014

Hi Robert,

Thank you again so very much for trying to help me.

I've tried this as well and am not having any luck. This is clearly out of my depth. So, I think I'm forced to concede defeat. :-(

I really appreciate you taking the time to reply to me. I don't think I can give you any Karma b/c this is a comment on a thread, but please know I'm sending virtual karma your way (if not digital karma). :-)

Stacia

Robert Reiner _smartics_
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.
June 23, 2014

Hi Stacia,

so now I have a lot of karma without being of any help? ;-)

This works on my work station:

https://www.smartics.eu/svn/public/sandbox/confluence-space-sandbox

If you create a page for the Sandbox Template, you will be directed to the page view instead of the default editor.

If you launch your debugger and look into the blueprint context, you'll see something like this:

{spaceKey=ds, parentPageId=819243, sandbox=Sandbox-Title}

I think you are too close to the solution to give up - sorry. :-)

Robert

Robert Reiner _smartics_
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.
June 23, 2014

Sorry again: What I forgot to add is the context after setting the title:

{spaceKey=ds, parentPageId=819243, sandbox=zzz, ContentPageTitle=zzz}

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events