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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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", "");

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?

I found option 1 worked perfectly for me. Thanks!

Works perfect for me too!!

Thank you!!

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.

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!

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 ;-) ...

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!

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

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

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}

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;
        }
    });
});

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

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

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

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
Community showcase
Published in Marketplace Apps & Integrations

Do Not Lose your Customer’s Trust

Missing deadlines is one of the biggest problems every team lead wants to avoid when dealing with managed services. When the customer contracts your company to help with IT services it is expected th...

20 views 0 0
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you