Forums

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

Macro in Macro

Christian Sprenger
Contributor
April 23, 2020

Can I create a user macro, which includes a macro with content?

Example

We have several documents, where we want to have a page-info with some content (table) for PDF export (Scroll PDF Export).

Now, for our authors it is annoying to always create this macro, add the same content, resp. to copy-paste it from a different page.
I also can not create a page and include the page to the document page, as the page info has always the same columns but mostly different content (document numbers etc).

 

My idea is to create a user macro, which the author can use, which adds the page info macro with the table already prepared. Kind of a template.

Has someone a sample user macro or can guide me to the direction?
I found some parts, but this does not work at all.
Maybe it does not work, I do not know.

 

Thanks for all replies :)

1 answer

1 accepted

1 vote
Answer accepted
Dominic Lagger
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.
April 23, 2020

Hi @Christian Sprenger 

I think, this would be possible. I'm interessted, what kind of information you want to display?

Depending on the information you want to display, you can easily make a user macro and display the parameters in a table. 

For example: 

## Macro title: ABC
## Macro has a body: N
##

## This is an example macro
## @param a:title=A|type=boolean|desc=A
## @param b:title=B|type=boolean|desc=B
## @param c:title=C|type=boolean|desc=C


<table id="myTable">
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>$parama</td>
<td>$paramb</td>
<td>$paramc</td>
</tr>
</table>

Include another macro

To include another macro, you can copy paste the "Storage Format" of the macro, like:

<ac:structured-macro ac:name="cheese" ac:schema-version="1" ac:macro-id="efb2934d-2e16-4a01-88a9-890c8ac3ce11" />

This is the storage format for the "I like Cheese " macro. Just copy that into your user macro. 

How to get to the Storage Format?

image.png

Hope this helps you a bit. If you have any further questions, let me know.

Regards, Dominic

Christian Sprenger
Contributor
April 23, 2020

Hello Dominic,

thanks for the fast reply.

When I see it correctly, this will create a user macro with a table and a macro.
But this will be independent, right? I will then have a table and beneath (or above) the macro, correct?

What I want to achieve actually is the macro with already added content, like a template.

PProperties.png

This is the content I require (well, more rows, but as example I think it explains it)

So, how can I add content in the page properties macro which I embed in my user macro?

Dominic Lagger
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.
April 24, 2020

I'm not quite sure I understand you correctly :) 

I try to explain.

A user macro renders its content when viewing the page. So the user macro looks different in the view mode and the edit mode. In the edit mode, you can't add a "template table". 

So for you, this would looks like this (I think):

User Macro

## This is an example macro
## @param title:title=Document Sub Title|type=string|desc=Document Sub Title
## @param number:title=Document Number|type=string|desc=Document Number
## @param release:title=Release Date|type=string|desc=Release Date




<table id="myTable">
<tr>
<td>Document Sub Title</td>
<td>$paramtitle</td>
</tr>
<tr>
<td>Document Number</td>
<td>$paramnumber</td>
</tr>
</tr>
<tr>
<td>Release Date</td>
<td>$paramrelease</td>
</tr>
</table>

Edit Mode from the macro

image.png

Edit Mode of the page

image.png

View Mode of the page

image.png

And if this is not the use case you want, I'm so sorry that I didn't understand you correctly... 

Let me know it.

Regards, Dominic

Christian Sprenger
Contributor
April 24, 2020

Hello Dominic,

well, I think, when I understand you correctly, that technically it does not work.

I require more a template for a user macro.

 

Imagine that:

You have 200 Documents and on every document you have to add a macro _Page Properties_ with a table inside the macro of properties (see picture above)

Instead of telling our author to add the page property-macro manually and to add the table manually with the exact same content on the left side of rows, I was thinking to have a macro, which implements exactly this: the page property macro with already prepared table with template content.

More like

UMac.png

Where, when I choose the User Macro, it adds the page properties macro with an embedded table.
Well, and actually, the page properties is hidden, it is only used for the PDF-Export. :D

 

Actually, I'd have a second use case, but let's focus on this one ;)

Dominic Lagger
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.
April 24, 2020

So I don't think this is possible with a user macro, I'm sorry...

What about a real template? 

Christian Sprenger
Contributor
April 24, 2020

You mean a Blueprint?

This works for new documents, that's true. I added that here already.

But we have loads of existing and I was hoping to solve it the easy way. 

Anyway, was worth a try.

Thanks for supporting.

Dominic Lagger
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.
April 24, 2020

Yes, a blueprint or a template. That's not the same.

Blueprints have index pages, can't be easily created and can't have predefined labels. 

Yeah, sorry for not working this out.

Regards, Dominic

Like Christian Sprenger likes this
Christian Sprenger
Contributor
April 24, 2020

No worries mate, thanks anyway for the useful information.
I'm pretty sure I'll have need of that on a later stage :)

 

Maybe I have to "reopen" this question as for a second case, but I have to re-think that :)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
6.15.2
TAGS
AUG Leaders

Atlassian Community Events