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

How to render spaceKey for macro in Blueprint template

Ewen Fortune July 22, 2014

Hi,

I'm developing a blueprint that creates a new space with a hierarchy pages, some of which contain macros such as the livesearch macro. How can I ensure the current spaceKey is set inside a template for a newly created space.

I had understood that I could use the at:var syntax in thesrc/main/resources/xml/space-home.xml

<at:var at:name="spaceKey" />

For example:

&lt;p&gt;
        &lt;ac:structured-macro ac:name="livesearch"&gt;
          &lt;ac:parameter ac:name="placeholder"&gt;Search this customer&lt;/ac:parameter&gt;
          &lt;ac:parameter ac:name="spaceKey"&gt;
            &lt;ri:space&gt;
				&lt;ri:space-key&gt;
					&lt;at:var at:name="spaceKey" at:rawxhtml="true"/&gt;
				&lt;/ri:space-key&gt;
		&lt;/ri:space&gt;
          &lt;/ac:parameter&gt;
        &lt;/ac:structured-macro&gt;
      &lt;/p&gt;

Is there a way to do this? - Do I have my syntax wrong?

Thanks,

Ewen

1 answer

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
Ewen Fortune July 22, 2014

OK.... syntax problem....

It was the surrounding xml that I actually had wrong, refactored like this and it works.

&lt;p&gt;
  &lt;ac:structured-macro ac:name="livesearch"&gt;
    &lt;ac:parameter ac:name="placeholder"&gt;Search this customer&lt;/ac:parameter&gt;
    &lt;ac:parameter ac:name="spaceKey"&gt;
              &lt;at:var at:name="spaceKey" /&gt;
    &lt;/ac:parameter&gt;
  &lt;/ac:structured-macro&gt;
&lt;/p&gt;

Sweet!

Ewen

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 23, 2015

It works on creation and I have used this for quite a while. But once you edit and save the page and you want to revert to the original page version later, you'll get a " java.lang.ClassCastException: java.lang.String cannot be cast to com.atlassian.confluence.content.render.xhtml.model.resource.identifiers.ResourceIdentifier". So it seems that not all uses cases for using a String instead of a ResourceIdentifier are properly handled by Confluence. Tested on Confluence 5.4.1.

Ulrich Hobelmann [catworkx]
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.
November 3, 2015

Same problem here. I get a ClassCastException, because Confluence seems to expect a space object, not just the space key (as string). How do I get it to expand <at:var...> into the actual space object?? Confluence 5.8.13

TAGS
AUG Leaders

Atlassian Community Events