Wiki source code of User Macro: Create Below Page
Version 1.1 by Normann P. Nielsen on 2026/11/15 15:43
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | = Purpose = |
| 2 | |||
| 3 | This create a Confluence button that starts a Page creation below a specified space/page combination(that must be valid). | ||
| 4 | |||
| 5 | An alternative to the standard "Create" button that alway creates below the current page. | ||
| 6 | |||
| 7 | |||
| 8 | |||
| 9 | = Details = | ||
| 10 | |||
| 11 | |= Macro Name| create-below-page | ||
| 12 | |= Macro-Title| Create Page below Parent | ||
| 13 | |= Description| This Macro creates a button that initiates a new Page creation under a specific existing Page | ||
| 14 | |= Categories| Confluence Content | ||
| 15 | |= Documentation URL| [[http://www.mos-eisley.dk/x/EIDzAg]] | ||
| 16 | |= Definition of User Macro| | (/)| No macro body | ||
| 17 | | (cross)| Escaped | ||
| 18 | | (cross)| Unrendered | ||
| 19 | | (cross)| Rendered | ||
| 20 | | (/)| No macro body | ||
| 21 | | (cross)| Escaped | ||
| 22 | | (cross)| Unrendered | ||
| 23 | | (cross)| Rendered | ||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | InĀ [[Custom HTML>>Main.atlassian.atlassian-confluence.styling-confluence.custom-html]], the button can be styled as: | ||
| 28 | |||
| 29 | |||
| 30 | {{code}} | ||
| 31 | .aui-button-below-page { | ||
| 32 | padding: 0px !important; | ||
| 33 | padding-left: 5px !important; | ||
| 34 | width: 20px !important; | ||
| 35 | height: 20px !important; } | ||
| 36 | {{/code}} | ||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | = Macro Code = | ||
| 41 | |||
| 42 | |||
| 43 | {{code}} | ||
| 44 | ## @param pagetitle:title=Page Title|type=string|required=true|desc= | ||
| 45 | ## @param spacekey:title=Space Key|type=string|required=false|desc= | ||
| 46 | ## @param buttontitle:title=Button Title|type=string|required=false|desc= | ||
| 47 | ## @param buttonhelptext:title=Button Helptext|type=string|required=false|desc= | ||
| 48 | ## @param buttoncolor:title=Button color|type=string|required=false|desc= | ||
| 49 | ## @param buttontextcolor:title=Button Textcolor|type=string|required=false|desc= | ||
| 50 | |||
| 51 | #set ($pageManager=$action.getPageManager()) | ||
| 52 | |||
| 53 | #if (${paramspacekey}) | ||
| 54 | #set($spacekey=${paramspacekey}) | ||
| 55 | #else | ||
| 56 | #set($spacekey=$renderContext.getOriginalContext().getSpaceKey()) | ||
| 57 | #end | ||
| 58 | |||
| 59 | #set($pageid=$pageManager.getPage($spacekey,"${parampagetitle}").getId()) | ||
| 60 | #if (${parambuttontitle} == "") | ||
| 61 | #set($buttontitle="Create Content") | ||
| 62 | #else | ||
| 63 | #set($buttontitle=${parambuttontitle}) | ||
| 64 | #end | ||
| 65 | |||
| 66 | #if ($pageid) | ||
| 67 | <a href="/pages/createpage.action?spaceKey=${spacekey}&fromPageId=$pageid" class="#header aui-button aui-style aui-button-primary aui-nav-imagelink aui-button-below-page" style="background: ${parambuttoncolor}; color: ${parambuttontextcolor};" title="${parambuttonhelptext}">$buttontitle</a> | ||
| 68 | #else | ||
| 69 | <a href="Javascript:;" title="Error in create-below-page macro: Space/page does not exist"><font color=red>ERROR</font></a> | ||
| 70 | #end | ||
| 71 | {{/code}} |