Configurable colour of a title in Expand macro
Asked by Anders Mynster S?rensen:

Hi,

I need to have different colours of title in the expand function. I should be able to change the colour of the title to red, green, yellow, purple, blue etc.

How can I do that?

I can't find any macros that can do that.


Answers:
author: Anders Mynster S?rensen
body: Hi Davin,

Thank you very much.

Can you please help me again.

I am not sure how much of the text/code I should add in the User Macro (Definition of User Macro \> Template)? And when I am in WIKI Markup, which code should I write to get the function work right?

**What I need is this:**   
(example with normal expand)

to get af normal expand-function without colors i write:

{expand:title=Title here}  
Text text text  
{expand}

Thank you in advance.


author: Davin Studer
body: Here is a user macro that does what you are wanting. You might want to fill out the style section a bit (padding, border, border-radius, etc). I've used the same colors that are used in the status macro for consistency.

**Macro Name:**   
color_expand

**Macro Title:**   
Color Expand

**Description:**   
Embeds an expandable text box into your page.

**Documentation URL:**   
<http://confluence.atlassian.com/display/DOC/Expand+Macro>

**Macro Body Processing:**   
Rendered

**Template:**

```
## Developed by: My Name## Date created: dd/mm/yyyy## Installed by: My Name## @param title:title=Title|type=string|default=Click here to expand...|desc=## @param color:title=Title Background Color|type=enum|enumValues=grey,red,yellow,green,blue|desc=################################ Create a unique id value #################################set( $id=$action.dateFormatter.calendar.timeInMillis )#if ($paramcolor == "grey")    #set ($backColor = "#CCCCCC")    #set ($textColor = "#3B73AF")#elseif ($paramcolor == "red")    #set ($backColor = "#D04437")    #set ($textColor = "#FFFFFF")#elseif ($paramcolor == "yellow")    #set ($backColor = "#FFD351")    #set ($textColor = "#3B73AF")#elseif ($paramcolor == "green")    #set ($backColor = "#14892C")    #set ($textColor = "#FFFFFF")#elseif ($paramcolor == "blue")    #set ($backColor = "#4A6785")    #set ($textColor = "#FFFFFF")#else    #set ($backColor = "transparent")    #set ($textColor = "#3B73AF")#end&lt;style type="text/css"&gt;#exp_cnt_$id .expand-control-text {    background: $backColor;    color: $textColor;}&lt;/style&gt;&lt;div id="exp_cnt_$id"&gt;    &lt;ac:structured-macro ac:name="expand"&gt;        #if($!paramtitle &amp;&amp; $!paramtitle != "")        &lt;ac:parameter ac:name="title"&gt;$!paramtitle&lt;/ac:parameter&gt;        #end        &lt;ac:rich-text-body&gt;            $body        &lt;/ac:rich-text-body&gt;    &lt;/ac:structured-macro&gt;&lt;/div&gt;
```

comments: author: Anders Mynster S?rensen
body: Hi Davin,Thank you very much.Can you please help me again.I am not sure how much of the text/code I should add in the User Macro (Definition of User Macro \> Template)?And when I am in WIKI Markup, which code should I write to get the function work right?What I need is this:(example with normal expand)to get af normal expand-function without colors i write:{expand:title=Title here}Text text text{expand}Thank you in advance.


author: Davin Studer
body: I edited my original user macro a bit(to fix a typo), so use the new one. When you are in the user maco definition the code block above is the template. Everything in that code block is part of the template. The stuff above the code block is for the other field in the user macro setup. As for wiki markup you would user this.{color_expand:title=Stuff\|color=red}Blah{color_expand}


Tags: confluence-administration