Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding markup to all children of a page

scott.gartner June 8, 2021

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?

2 answers

0 votes
Hyrum Steffensen _Appfire_
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.
June 8, 2021

Hello Scott,

One possibility would be to use Power Scripts for Confluence to move pages using the movePage() routine or clonePageTree()

Regards,

Hyrum

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

scott.gartner June 8, 2021

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

Hyrum Steffensen _Appfire_
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.
June 8, 2021

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

Here is documentation on the getPage() routine. Here is documentation on setting variables.

You may also be interested on Power Scripts' integration with Comala Workflows. 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.

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

Hyrum Steffensen _Appfire_
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.
June 8, 2021

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.

Another option is using CQL to find pages.

Regards,

Hyrum

0 votes
Brant Schroeder
Community Champion
June 8, 2021

@scott.gartner 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/  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.

scott.gartner June 8, 2021

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 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

Brant Schroeder
Community Champion
June 8, 2021

@scott.gartner 

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.

scott.gartner June 8, 2021

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events