Generate a list of redirecting pages
Scenario
The Redirect macro (from the add-on Redirection for Confluence) lets you set a page redirection. This is useful to redirect users from an old page to a new one, especially after removing or updating pages.
This recipe generates a list of pages containing the Redirect macro. A non-redirecting link is included with additional options to view, edit, or remove the page.
Result
Recipe
Apps | Linking for Confluence, Reporting for Confluence Data Center, Redirection for Confluence |
|---|---|
Level | Intermediate |
Estimated time | 20 minutes |
Macros | Content Reporter, Report Column, Report Info, Report Link, Report Table, Text Filter, Text Sort |
Suppliers | Page Supplier |
Storage format
You can copy and paste this code into the Confluence Source Editor:
<ac:structured-macro ac:macro-id="f7d310fd-a355-4b71-9e92-be072d21e17b" ac:name="report-table" ac:schema-version="1">
<ac:rich-text-body>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="44659df1-4309-462f-a62e-a205ba17f7eb" ac:name="content-reporter" ac:schema-version="1">
<ac:parameter ac:name="types">+page</ac:parameter>
<ac:parameter ac:name="spaces">
<ri:space ri:space-key="@global" />
</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="8eeed64e-acac-4514-b939-0ad0717b8b3e" ac:name="text-filter" ac:schema-version="1">
<ac:parameter ac:name="include">.*redirect.*</ac:parameter>
<ac:parameter ac:name="">page:body > body:text</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="d05961c7-74a6-4c31-92c0-3063b75e741f" ac:name="text-sort" ac:schema-version="1">
<ac:parameter ac:name="">page:space</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="e36addfd-7f4d-41e5-88c1-a7b470f94314" ac:name="text-sort" ac:schema-version="1">
<ac:parameter ac:name="">page:title</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="218dd95a-31eb-4418-9296-0d4754f065f3" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Page Title</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="3ff36c6c-c462-4210-96cb-19ebd782b883" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">page:title</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="8a0a62dc-625e-4c5a-809f-f82d16212626" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Space</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="fa0b57ab-9a7c-45e2-b335-4129a24235b0" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">page:space</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="fe1cf538-41e4-4485-94e0-87cf43ea1f14" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:parameter ac:name="title">Actions</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="2adb506c-298a-4cd1-ab07-ac088eb67866" ac:name="report-link" ac:schema-version="1">
<ac:parameter ac:name="postfix">?&redirect=false</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:parameter ac:name="">page:url</ac:parameter>
<ac:rich-text-body>
<p>View</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="11f7c459-fe37-41de-aaf7-e2841e49aee5" ac:name="link-to" ac:schema-version="1">
<ac:parameter ac:name="linkText">Edit</ac:parameter>
<ac:parameter ac:name="content">
<ac:link>
<ri:page ri:content-title="%title%" ri:space-key="REP" />
</ac:link>
</ac:parameter>
<ac:parameter ac:name="">page edit</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="b0b1faf3-b960-4c11-b2cd-c5d10605a01a" ac:name="link-to" ac:schema-version="1">
<ac:parameter ac:name="linkText">Remove</ac:parameter>
<ac:parameter ac:name="content">
<ac:link>
<ri:page ri:content-title="%title%" ri:space-key="REP" />
</ac:link>
</ac:parameter>
<ac:parameter ac:name="">page remove</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
Macro structure
You can recreate the example in the editor view:
Steps
Create a Report Table macro.
Within the Report Table, create a Content Reporter macro with the following parameters:
Spaces:
@globalTypes:
+page
Within the Report Table, under the Content Reporter, create a Report Column macro with the Title parameter set to
Page Title.Within the Report Column macro, create a Report Info macro with the Key parameter set to
page:title.Under the Page Title Report Column macro, create a Report Column macro with the Title parameter set to
Space.Within the Space Report Column macro, create a Report Info macro with the Key parameter set to
page:space.Under the Space Report Column macro, create a Report Column macro with the Title parameter set to
Actionsand select Injected.Within the Actions Report Column macro, create a Report Link macro with the following parameters:
Key:
page:URLURL postfix:
?&redirect=false
Within the Report Link macro body, enter the text
Link.Within the Actions Report Column macro, under the Report Link macro, create a Link to Location macro with the following parameters:
Location:
page editLink Text:
EditContent:
%title%
Next to the Link to Location macro, create another Link to Location macro with the following parameters:
Location:
page removeLink Text:
RemoveContent:
%title%