Add template to top of existing page. How to
Asked by T. Frank:

Hi all,  

I need to be able to add a template to some existing pages in way that it is editable in editor in whole (no include).  
I tried by adding a user macro to page which uses AJS.toInit(), resulting in the code to be seen as text on page only.   

First, a there any options to be enabled (html macro is enabled!?) besides the user macro rendering options, resources to be defined? As total novice to Confluence 4.1.3 I would appreciate some advice.


Answers:
author: Matthew J. Horn
body: I'm not sure exactly what you're looking for. Have you checked out the Page Layout and Global Layout templates in the Space Admin? This would be where I would add content that I want to appear on existing pages. It won't let you edit that shared content plus your body text at teh same time, but that should be the case anyway.

comments: author: T. Frank
body: Thanks for reply - here is what I'm looking for:)  
Some pages need to be get a header that user has to enrich, resp. a template. In order to do so I thought about a user macro which lets user easy add the template. Concatenated content should be seen in editor so user can fill out the integrated header.  
I tried code from Use jquery load() function but macro source is "rendered" as text to page, so I guess st. is missing, needs to be activated?


author: Bob Swift (personal)
body: You might want to consider just adding standard text to your existing pages. Of course, once added it becomes part of the page and is no longer "a template", but often we just use the term template to reference standard text blocks. Here is an example that shows how to automate this:

[How to automate adding text to Confluence pages](https://bobswift.atlassian.net/wiki/display/CSOAP/How+to+automate+adding+text+to+Confluence+pages)

comments: author: T. Frank
body: Thanks for your tip but I can't confront users with command line. As I said, getting the 'user macro' to be executed would probably solve.


author: Bob Swift (personal)
body: I didn't understand your question then, so, you want a user while editing a page to be able to draw in a chunk of standard text, make changes and have it part of the page.

We would use a different approach for situations similar to this by using: <https://marketplace.atlassian.com/plugins/net.customware.confluence.plugin.scaffolding>


author: T. Frank
body: You're welcome and thx for the answer - but our budget has reached its limit.  
So I went back to the user macro which puts "tinyMCE is not defined" error to  
console - which means that the appropiate .js is not properly included??  

```
## @noparams&lt;script type="text/javascript"&gt;   AJS.$(document).ready(function(){      alert( "Is tinymce active editor: "+tinyMCE.activeEditor );   } );&lt;/script&gt;
```


author: Matthew J. Horn
body: I think what you want are user templates. You define them and then when you create a page, you can set the template on the page. The contents of the templates are copied into the page when it is created so the user can edit it just as they would other user content.

Here's more info on user templates:

<https://confluence.atlassian.com/display/DOC/Working+with+Templates>

comments: author: T. Frank
body: Thanks, we are getting closer:)  
I redescribe: "Is it possible to add a template to existing pages without recreating the pages?"  
This was asked 2010 and the answer was "no, not yet" ([see question](https://confluence.atlassian.com/display/DOC/Working+with+Templates?focusedCommentId=214863135#comment-214863135)).  

But what I understand from [jquery load() function](/questions/61114/use-jquery-load-function) is that it gets the content from page b, resp. a template, concatenates it with content from current page a and loads it to tinymce editor, which is pretty much what I want - I guess.  

The problem is: As result I just see the code of the macro as new page content. How do I getting scripting to work? St. is missing, needs to be activated? A resource needs to e defined?


Tags: ajs

tiny-mce

user-macro