Conditional page extraction
Asked by HARTMANN Remi:

Hi there,

I would like to create a user macro that allows me to :

- Extract a page from a multi-project space

- Filter the information according to the desired project (a text field to select the desired project).

Thanks in advance


Answers:
author: Kristian Klima
body: Hi [@HARTMANN Remi](/t5/user/viewprofilepage/user-id/5436194) and welcome to the Community.

There's an app for that in the Confluence Marketplace already. Two apps, actually, both made by K15t.

[Scroll Versions](https://agent-docs.emplifi.io/home/Production/) and [Scroll Documents](https://marketplace.atlassian.com/apps/1217608/scroll-documents-for-confluence?hosting=datacenter&tab=overview) with its [Variants](https://marketplace.atlassian.com/apps/1226295/variants-for-scroll-documents?hosting=datacenter&tab=overview) add on support creating conditional content on Confluence, as far as I know, those are the only apps to do that.

I've used them both.

---------

With Scroll Versions, I created a documentation space for three different product pricing tiers, using conditionals to determining which content appears in which combination of the product tiers docs. It's all switchable and worked great. Edit in a single space, create multiple docs variants.

--------

With Scroll Documents and Variants, the use case is Public and Internal Documentation.

Again, a single Confluence space to author in, two variants of the docs. I can select which pages are internal only, public only or both. I can also select which SECTION of a page is internal only. So in the Release Notes page I can have a section with a link to Jira that only appears in the Internal version.

---------

Setup is really easy in both apps although I prefer the Scroll Docs with Variants as it takes minutes to set up (and you can also use it apply labels to pages en masse).

Both apps also support semantic versioning so you can create your docs v. 1.2, 1.3, etc.

Disclaimer: I do not work for K15t.

comments: author: HARTMANN Remi
body: Hi Kristian Kima

Thank you for your prompt reply.  
I will test the solution and give you my feedback.


author: HARTMANN Remi
body: I was able to try out your solution.

I think it's a good alternative if you only have one space for all your projects.

In my case, we have one space for each project (historical definition), and we've created a new space to pool all the information (requirements, project specifics, etc.).  
My aim is to distribute this information according to projects in their own dedicated areas (workspaces and project document extraction areas for audit preparation and other process points).

eg:

- Common space

- req_Projet1_1 : ....

- req_Projet2_1: ....

- req_Commun_2: ....

- req_Projet1_2 : ....

- Project1 space

- req_Projet1_1 : ....

- req_Commun_2 : ....

- req_Projet1_2 : ....

- Project2 space

- req_Projet2_1 : ....

- req_Commun_2 : ....

So I'm thinking of including pages from the common area in the dedicated areas by filtering requirements and information by project.

eq : Include_page(page_espace_commun/filtre = (Project1 or Common))


author: Kristian Klima
body: [@HARTMANN Remi](/t5/user/viewprofilepage/user-id/5436194)

It seems that you have an intriguing use-case.

If I'm not mistaken, Scroll Documents does have a feature that allows you to create documents with cross-space content. I'm not using it myself.

Perhaps [@Max Foerster - K15t](/t5/user/viewprofilepage/user-id/693014) could shed some light on this of connect you with those in the know.


author: HARTMANN Remi
body: Thank you for your prompt reply

I'll look for the information you've just given me.


author: Max Foerster - K15t
body: Hey [@HARTMANN Remi](/t5/user/viewprofilepage/user-id/5436194) ??

I encourage you to [book a demo](https://www.k15t.com/products/scroll-apps-for-confluence) with us on our website to discuss your use case with our team in more detail.

Thanks, [@Kristian Klima](/t5/user/viewprofilepage/user-id/5074962), for looping me in!


author: Anas Ibrahim
body: Creating a user macro in Atlassian Confluence to extract a page from a multi-project space and filter the information according to the desired project can be achieved by defining a macro that includes user input fields and programming logic to filter content based on the selected project. Here's a basic example of how you might approach this task:

Define the User Macro:

Go to Confluence Administration and select User Macros.  
Click Create a User Macro and fill out the fields such as Name, Description, and other macro details.  
Macro Template:

Write the macro template to include a text field where users can input the desired project name.  
Use Confluence's scripting capabilities to filter and display the content based on the input.  
Here is a simple example in the FreeMarker Markup Language (FML):

```
## Macro name: projectFilterMacro
## Macro title: Project Filter Macro
## Description: Filters content based on project name input
## Macro input: 
## - projectName: Text (single-line input), Required, no default.

## @param projectName:title=Project Name|type=string|required=true|desc=Enter the project name to filter content

<ac:structured-macro ac:name="excerpt-include">
<ac:parameter ac:name="nopanel">true</ac:parameter>
<ac:parameter ac:name="context">page</ac:parameter>
<ac:parameter ac:name="excerpt">">

## Filter pages by project name
#set($projectName = $paramprojectName)
#if($projectName)
<ac:structured-macro ac:name="content-report-table">
<ac:parameter ac:name="space">MULTI_PROJECT_SPACE_KEY</ac:parameter>
<ac:parameter ac:name="maxResults">10</ac:parameter>
<ac:parameter ac:name="title">Pages for $projectName</ac:parameter>
<ac:parameter ac:name="cql">
type = page AND label in (project-$projectName) AND space = MULTI_PROJECT_SPACE_KEY
</ac:parameter>
<ac:parameter ac:name="columns">title, created, creator</ac:parameter>
</ac:structured-macro>
#else
<p>Please enter a project name to filter the content.</p>
#end
```

<br />

Usage:  
Place the macro on a Confluence page where you want the filtered results to appear.  
Users can then input the desired project name, and the macro will display the relevant pages from the specified multi-project space.  
This macro uses the content-report-table Confluence macro with a CQL (Confluence Query Language) parameter to filter pages based on the project label. Replace MULTI_PROJECT_SPACE_KEY with your actual Confluence space key.

Notes:  
Space Key: Ensure that the space key (MULTI_PROJECT_SPACE_KEY) is correctly specified to target the right multi-project space.

Labeling: Pages should be appropriately labeled (e.g., project-ProjectName) to be filtered effectively.

Additional Customization: You might need to adjust the macro parameters and CQL filters based on your specific requirements and Confluence setup.

comments: author: HARTMANN Remi
body: Hi Anas Ibrahim

Thank you for your prompt reply.  
I will test the solution and give you my feedback.


author: HARTMANN Remi
body: Hi [@Anas Ibrahim](/t5/user/viewprofilepage/user-id/2481496) ,

Is it possible to make calls and use atlassian macros in user macros?

For example, I'd like to use the Atlassian macro "includ page" and then overlay it to filter the information to be displayed?


Tags: confluence-data-center

data-center