Missed Team ’24? Catch up on announcements here.

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

Blueprint template: ri:username='at:var'

Robin Peters
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 6, 2014

Hey,

I created a blueprint with a wizard where the user could chose users as stakeholders (with "class='autocomplete-multiuser'").

But now, there should be a table on the top of the generated page which show the users not as plain text but as @mention tags.

In the source editor, I can see the mentions are stored as "<ri:user ri:username="name"/>. How can I add there a <at:var at:name="id"/>?

At the moment, I use a onBlueprintCreateEvent-method to cast the plain text to mention when the page is created, but it will be quiet nice if I don't have to go this detour.

Regards,

Robin

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

6 votes
Answer accepted
Niraj Bhawnani
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 3, 2014

Have you tried this approach? In your template:

&lt;at:var at:name="mentionsGoHere" at:rawxhtml="true"&gt;

In your context provider:

context.put("mentionsGoHere", "&lt;ri:user ri:username=\"name\"/&gt;");

The rawxhtml attribute tells Confluence not to escape things and to inject the markup directly into the template.

Jason Nguyen May 15, 2014

Thanks Niraj, this helps.

Robin Peters
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.
May 22, 2014

Yep, that helped me too.
Works for me now without the detour.

Thanks!

winter wong November 1, 2017
SyntaxEditor Code Snippet
"<ri:url ri:value=" + "\"" + imagefile + "\"" + " />";
0 votes
Jason Nguyen April 2, 2014

Hey Robin, thanks for the response. How are you editing the plain text of your page with your listener? I am trying to do the same thing but can't retrieve the .xml of my Space blueprint home page programatically. I thought event.getSpace().getHomePage().getBodyAsString(); would get me my home page but it seems to get some default Confluence one rather than the one I specified in my atlassian-plugin.xml at this point. EDIT: I figured out the work around, my listener listens for a a BlueprintPageCreateEvent and I can grab the page body through there.

@EventListener
    public void spaceBlueprintCreateEvent(SpaceBlueprintCreateEvent event){
        Map&lt;String,Object&gt; context = event.getContext();
        log.error("Space Blueprint Create Event: "+event);
        log.error("Context = "+event.getContext());

        String homePageBody = event.getSpace().getHomePage().getBodyAsString(); //get the home page of the body, and then replace the at:var tags or whatever
        String designManagerName = context.get("designManagerName").toString();
        String projectManagerName = context.get("projectManagerName").toString();
        String marketingManagerName = context.get("marketingManagerName").toString();
        homePageBody = homePageBody.replace("designManagerName", designManagerName).replace("projectManagerName", projectManagerName).replace("marketingManagerName", marketingManagerName);
        log.error("New homepage body "+homePageBody);
        event.getSpace().getHomePage().setBodyAsString(homePageBody); //replace the old body with the one with the new names.

    }

0 votes
Jason Nguyen April 2, 2014

Hey Robin, I am having the similar issue. Have you ever found a work around?

Robin Peters
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.
April 2, 2014

No, sorry. I'm still using my workaround.

TAGS
AUG Leaders

Atlassian Community Events