Adding markup to all children of a page
Asked by scott.gartner:

We have a page where we store all the outdated pages. We want to keep the pages around since they contain historical information. The issue is that users can find these pages using search and not easily notice that they have been moved to the archived page tree. Is there a way to change the parent page in this tree such that it would add some warning text to each child automatically? I thought maybe I could change the Page Template or Page Layout for the page and have that apply to its children, but I was unable to find any way to do that (maybe it's possible and I don't have enough permissions to do that).

Ideas?


Answers:
author: Hyrum Steffensen _Appfire_
body: Hello Scott,

One possibility would be to use Power Scripts for Confluence to move pages using the [movePage() routine](https://anovaapps.atlassian.net/wiki/spaces/PSCONF/pages/1840429/movePage) or [clonePageTree()](https://anovaapps.atlassian.net/wiki/spaces/PSCONF/pages/1840267/clonePageTree).

Regards,

Hyrum

Full disclosure, I a product engineer for Power Scripts and work for Anova Apps, an Appfire company.

comments: author: scott.gartner
body: Hyrum,

Thanks for the reply. How would moving or cloning the pages do the job? They would still not indicate that they were out of date. The goal is to have an indication at the top of the page that the data on the page is old (without having to edit each and every page and remembering to edit any future pages). They are where we want them to be in the space.

Scott


author: Hyrum Steffensen _Appfire_
body: Hello Scott,

Please see this example script for adding a date at the top of the page:

number id = getPage("Demo", "Example Page");  
%id%.content = "\<p\>" + currentDate() + "\\n\\n" + id.content + "\</p\>";

Here is what the page looks like:

![Screen Shot 2021-06-08 at 8.13.33 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/146676i8DA17E0BFE1EABC5/image-size/large?v=v2&px=999 "Screen Shot 2021-06-08 at 8.13.33 PM.png")

Here is documentation on the [getPage() routine](https://anovaapps.atlassian.net/wiki/spaces/PSCONF/pages/1840311/getPage). Here is documentation on [setting variables](https://anovaapps.atlassian.net/wiki/spaces/SIL/pages/1829130/Variable+resolution).

You may also be interested on Power Scripts' integration with [Comala Workflows](https://anovaapps.atlassian.net/wiki/spaces/CTR/pages/2150864/Comala+Workflows+-+Archive+page). Comala Workflows is really interesting in that you can create a workflow for pages (similar to a Jira issue workflow) that is useful for creating a cycle for pages and [managing the process of archiving pages](https://wiki.comalatech.com/display/CDML/Welcome+to+Comala+Document+Management).

The idea here is that you could use Comala Workflows to manage the process that in turn would run a SIL script based on a workflow event.

Due to Confluence Cloud security features, you may need to open the documentation in incognito mode or by logging out of Confluence.

Regards,

Hyrum


author: Hyrum Steffensen _Appfire_
body: Scott,

You can also move through the page tree starting at the parent. something like:

number parent = getPage("Demo", "Example Page");

number \[\] children = getChildPages(parent);  

for(number childPage in children) {

%childPage%.content = "\<p\>" + currentDate() + "\\n\\n" + childPage.content + "\</p\>";

}

Here is the documentation for [getChildPages](https://anovaapps.atlassian.net/wiki/spaces/PSCONF/pages/1841583/getChildPages).

Another option is using [CQL to find pages](https://anovaapps.atlassian.net/wiki/spaces/PSCONF/pages/1840928/selectPages).

Regards,

Hyrum


author: Brant Schroeder
body: [@scott.gartner](/t5/user/viewprofilepage/user-id/4428582) Welcome to the Atlassian Community

If you are using the archive feature they will not show up in search [https://support.atlassian.com/confluence-cloud/docs/archive-pages/](https://support.atlassian.com/confluence-cloud/docs/archive-pages/?) This feature is available on all paid plans.

There is no way to bulk update pages natively in Confluence other than the rest API. So really your choices are listed below to bulk edit pages or change their template.

1. Confluence REST API
2. Plugin
3. Update content manually
4. Update code manually
5. Export/edit/import

If you are on a free plan you can always use page permissions to hide the page from other users.

comments: author: scott.gartner
body: Brant,

Thanks for the response. The pages are not archived, but they have all been moved under one specific page (sometimes whole trees of pages were moved). The goal isn't to hide the pages, but instead to warn the user that the information is at least partially out of date.

I saw some [other people talking about adding a macro to the Page Layout](https://community.atlassian.com/t5/Confluence-questions/Confluence-apply-a-macro-to-all-children-pages-of-a-space/qaq-p/36058) for the space, but the problem there is figuring out if the page is in the required part of the tree (that discussion involved changing all pages in the space, but I only want to modify some pages).

I don't know if these macros they are talking about are running on the client (JavaScript) or the server (Velocity?), or if there is a way in either of these to walk up the current page's parentage tree to see if it needs the special markup.

Scott


author: Brant Schroeder
body: [@scott.gartner](/t5/user/viewprofilepage/user-id/4428582)

Is there a need to keep them in the same space or could they be migrated to an archive space?

If you could move them all to the same space then you could apply a macro to the page template and identify them as being archived. Otherwise, you will need to touch each page individually to add it to the page or change the page template.


author: scott.gartner
body: Brant,

Yeah, I was trying to avoid touching all the pages, there are quite a lot of them. Plus it would be an ongoing problem as new pages are moved into that tree, someone would have to remember to apply any individual change. That's why I was looking for a generic solution at the "space" level.

If we move them to their own space, they will stop coming up in search results for this space (to which they do actually belong, they are just old/deprecated).

Also, we do have archived pages in Confluence and the archived pages do still come up in the search results in that space. Interestingly, pages that are archived all get a consistent banner on them. I wonder how that is implemented in Confluence (maybe they created a special flag, which they can use to decide when to add the "archive" banner).

Thanks for the ideas though,

Scott


Tags: cloud

confluence-cloud