Hi all
We have Scroll Version for Confluence. With this we are able to create multiple versions of one page.
We also can add a "Page Key". A page key can be added manually.
Now I wanted to create a list of all pages in this space and their page key, if they have one.
But I don't see anything where this information is stored...
How can I get access to this information? I want to create an user macro.
I'm using also ScriptRunner, so also a ScriptRunner solution is highly appreciated.
Regards, Dominic
Here is a custom user macro definition that might be helpful for you. Placing it on any page will render a table with all pages with keys, their keys, and the versions for the current space. You can restrict the page to not interfere with the rest of your documentation. To re-create it in your instance, select the following settings:
In the Template part, enter the following definition:
## @noparams
<table class="confluenceTable tablesorter tablesorter-default" >
<thead class="tableFloatingHeaderOriginal">
<tr role="row">
<th class="confluenceTh">Page name</th>
<th class="confluenceTh">Page key</th>
<th class="confluenceTh">Version</th>
</tr>
</thead>
<tbody id="pk-table-output"></tbody>
</table>
<script>
let baseUrl = Confluence.getBaseUrl().concat(Confluence.getContextPath());
let spaceKey = AJS.Meta.get("space-key");
console.log(baseUrl);
function pkArray(pkPages) {
var pkTable = "";
var i=0;
while (i < pkPages.length) {
var page = pkPages[i];
if (page.scrollPageKey != undefined) {
pkTable = pkTable.concat("<tr role='row' ><td class='confluenceTd'><a href='"+baseUrl+"/pages/viewpage.action?pageId="+page.confluencePageId+"'>"+page.scrollPageTitle+"</a></td><td class='confluenceTd'><a href='"+baseUrl+"/display/_PK/"+spaceKey+"/"+page.scrollPageKey+"'>"+page.scrollPageKey+"</a></td><td class='confluenceTd'>"+page.targetVersion.name+"</td></tr>");
}
i++;
}
return pkTable;
}
let pkRequest = new XMLHttpRequest();
pkRequest.open("POST", ""+baseUrl+"/rest/scroll-versions/1.0/page/"+spaceKey);
pkRequest.setRequestHeader("Content-Type", "application/json");
pkRequest.send(JSON.stringify([{"queryArg": "scrollPageKey", "value": "*"}]));
pkRequest.onload = () => {
if(pkRequest.status === 200) {
document.getElementById("pk-table-output").innerHTML = pkArray(JSON.parse(pkRequest.response));
}
else {
console.log("whoopsie")
}
}
</script>
If this doesn't work for you, feel free to reach out to use: support@k15t.com.
This works great, thanks!
Is there any possibility to get a list from all the pages, which doesn't have any page key?
Regards, Dominic
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found a possible solution, but I'm not sure if it's correct:
Change the queryArg:
pkRequest.send(JSON.stringify([{"queryArg": "scrollPageKey", "value": "*"}]));
And change the if statement:
if (page.scrollPageKey != undefined) {
pkTable = pkTable.concat("HTML HERE");
}else{
pkTable = pkTable.concat("HTML HERE");
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.