Automatically create/add a page

Tom Crapper September 25, 2011

Hi,

I have several templates to make it easier for users to add stuctured content.

I want to also add unstructured content to the created pages, but wish to do this by automatically creating/adding a child page to the one renderd through the template.

USE CASE:

A user clicks a link that takes him/her to a template form; this will create a new page in that space. (done this bit).

So, when finished, the user clicks 'Save' and the form creates a new page. IN ADDITION, a child page is created (based upon that parent page name) and is imbedded inside the parent page (using the Include Page Macro {include:...}).

WHY?

In doing this, I can have a repository of structured data which can be efficiently presented, searched etc, AND a running notes/test area on the page which can be manipulated by users on the fly. This way, I get a really rich and rapidly grown repository for my userbase.

1 answer

0 votes
Tom Crapper October 20, 2011

Cracked it (well, in fact Mick Roff did!!! This solution includes his text. Thanks Mick!)

Firstly, put the create childs in a report to minimise when the report is run. This is set it up only to run within the first 60 seconds of the parent page being created. This ensures child pages that have been spawned can be deleted if required. If you don’t have this restriction, then the child pages will continue to be spawned if they are not present.

Then, the use of the replace and render function allows you to replace %title% with the name of the parent page.

Finally, add a {create-child} macro (in a {replace} macro) to add a child page of the correct title.

Should look like:

{report-block}
{local-reporter:content:creation date}
{date-filter:creation date|afterValue=-60s|format=hh:mm:ss dd MMM, yyyy}
{local-reporter}
{report-body}
{replace-and-render} {replace-body}
{create-child:%title% - Notes|parent=@self|template=Notes Page}
   {create-child:Grandchild Page -%title%|parent=Child Page -%title%|template=Blank }
{replace-body} {replace-item:%title%} {report-info:report:root content > page:title}{replace-item} {replace-and-render}
{report-body}
{report-block}

And:

{replace-and-render} {replace-body}
{create-child:Child Page -%title%|parent=@self|template=Blank }
   {create-child:Grandchild %title% - Notes|parent=Child Page -%title%| }
{replace-body} {replace-item:%title%} {report-info:report:root content > page:title}{replace-item} {replace-and-render}

The next thing I have to work out is how to automatically pre-fill the notes page (either with a template or without) in order that It renders content as soon as the main page template is saved. At the moment, it shows the pink 'macro error' lines of text where the child pages should render, which is not fixed until they are opened, edited and saved (which completes the parent page).

Any answers to that last piece of the jigsaw?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events