Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Add row to a table after table is created with a macro.

E Lore January 11, 2012

I've got a macro (patchdoc) that creates a table with given information (all in ## @param form) and it only creates the table header row and one data row. I'm trying to get an addrow macro where I can add a row to this table (the one created from patchdoc) given the information (again in the @param form) much like the first macro. I've tried adding it to the $body of patchdoc but it never converts it to the table. I can only get the addrow macro into the body of patchdoc if it's body type is set as "rendered" but, the table never renders.. it just outputs the information above the patchdoc table.

I'm creating the table using the <table> and <tr> tags. In the addrow macro I have the ## @param (which is the only way I know of requesting user input before the macro is created besides the body) set to ask for the info in each column. The addrow then takes the param info and puts it between <tr><td>params</td></tr> tags.

So it's basically this: {patchdoc}({addrow}) and no matter what I try, adding a row doesn't work. although the patchdoc table renders properly.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Aseem Parikh January 12, 2012

Hi Elore,

Your patchdoc macro should look something like this:

<table class="aui">
    <thead>
        <tr>
            <th>Column 1</th>
            <th>Column 2</th>
        </tr>
    </thead>

    <tbody>
        <tr>
            <td>Row 1, Col 1</td>
            <td>Row 1, Col 2</td>
        <tr>
        $!body
    </tbody>
</table>

Note: Be sure to select the "Convert wiki markup to HTML" option

And your addrow macro should look something like this:

        <tr>
            <td>$!paramcell1</td>
            <td>$!paramcell2</td>
        </tr>

On your pages, you should now be able to do something like this:

{patchdoc}
    {addrow:cell1=Row 2, Col 1|cell2=Row 2, Col 2}
{patchdoc}

E Lore January 15, 2012

I don't see any option for "Convert wiki markup to HTML".
I'm using confluence 4.1. The closest I saw to that was marking the macro body rendered.

How do I add that second {patchdoc} macro below it? When the patchdoc macro is created it requests required information from the user. I can't add a blank patchdoc macro. Or is that supposed to indicate to put the addrow macro in the body of the {patchdoc} macro? I've tried that and it doesn't work using this method.

Both {patchdoc} and {addrow} pop up a prompt asking for required information before the macro is created. When I try this it just does with it normally does and renders the {patchdoc} correctly, but puts the info in {addrow} above the table {patchdoc} creates and doesn't even put the {addrow} information into a table row, just displays the information as 1 param perline.

Also on the second <tr> under <tbody> there is a <tr> that isn't closed with /. Is this on purpose or just an oversight?

TAGS
AUG Leaders

Atlassian Community Events