Communardo Software GmbH, Kleiststraße 10 a, D-01129 Dresden
0800 1 255 255

Wikipage to page template since Confluence 4

All day work is much easier since Confluence 4. You are able to create com­plex Wiki pages without knowing some­thing about Wiki Markup.  But if you want to use page tem­pla­tes you get in some trou­bles because they still need Wiki Markup. So, how can we create a page tem­plate from an exis­ting wiki page?

We can solve this pro­blem with a little user macro. These are the steps to do:

Determine the  storage format of the source page

  • Choose a page that you want to use as tem­plate and select "Tools" > "View Source". 
    • A popup win­dow will appear… sim­ply let it open

Create the helper usermacro

The user macro is nee­ded to store the page source to the newly crea­ted page. It only have to be crea­ted once and can be used on all page templates.

  • Create the user macro via the glo­bal admi­nis­tra­tion and define the fol­lowing values. 
    • Macro Name: wraptemplate
    • Macro Title: wraptemplate
    • Visiblility:  Visible only to sys­tem admi­nis­tra­tors in the Macro Browser
    • Macro Body Processing: Unrendered
    • Template:
## @noparams
$content.setBodyAsString($body)
#if($content.title)   
    <script type="text/javascript">       
        window.location.reload()   
    </script>
#end
  • Save the usermacro

Create the page template

  • Now create your page­tem­plate via the glo­bal admi­nis­tra­tion -> glo­bal templates
  • Inside the tem­plate we call the user­ma­cro like this: "{wrap­tem­plate} <STORAGEFORMAT> {wrap­tem­plate}"
    • Insert the sto­rage for­mat of the source page  ins­tead of <STORAGEFORMAT> (find it in the still ope­ned popup window)
  • Save the template

What happens inside ?

A page tem­plate sim­ply inserts its text/wikimarkup to the newly crea­ted page. In this case it is the "wrap­tema­plate" usermacro.

The user­ma­cro has the task to save the sto­rage for­mat (which is defi­ned in its body) to the crea­ted page.

The user­ma­cro is doing its save pro­cess during the the page ren­de­ring. This results in an empty page after crea­ting a page from the tem­plate. The tem­plate text appears after a simple page rel­oad. This page releading is also done by the user macro. That's the rea­son for the little page fli­cke­ring during the page crea­tion with such a template.

27. Juni 2012

Avatar Henning Köhler

Thanks for sharing this solu­tion, it works well and crea­tes a "real and edita­ble page".

But when crea­ting a page from the tem­plate the user sees all the "XML source code" , and has to save one time end edit again to see the final page. This may be con­fu­sing or sur­pri­sing for most users.

It would be best to have a tool or macro that crea­tes "real" mark up code, that can pe pas­ted into the page tem­plate as requi­red. Do you know of anyone working on this?

A repre­sen­ta­tive from Atlassian told me on a User Group Munich Meeting a week ago that Rich Text Editor edi­t­ing of page tem­pla­tes was post­po­ned from ver­sion 4.3 to ver­sion 4.4 of Confluence, so it may take ano­t­her year 🙁

Avatar Sandro Herrmann

Yes you are right. The XML code is quite con­fu­sing and a real Plugin for sol­ving this pro­blem would be nice. But we all hoped to get the 4.3 ver­sion of Confluence where all that pro­blems got fixed.
Thanks for your state­ment about the poten­tial fea­ture move­ment to CF 4.4. I hope someone is buil­ding a real plugin solu­tion to work with tem­pla­tes until it is sup­por­ted by atlassian.

Henning,

I'm unsure who told you that rich text edi­t­ing for crea­ting and edi­t­ing tem­pla­tes was being pushed from 4.3 because it is in 4.3 🙂 You can try it today in the Confluence 4.3 Beta 1 releas:

https://confluence.atlassian.com/display/DOC/Confluence+4.3‑Beta1+Release+Notes

Cheers
Matt Hodges
Confluence Group Marketing Manager

Comments are closed.

Pin It on Pinterest