Creates a pulldown menu of spaces based on a given tag
| Warning This requires Confluence 2.8! |
| Dependencies This requires the SQL Plugin to function. You will need to create a Confluence Datasource called ConfluenceDS |
Overview
This creates a Confluence 2.8 style pulldown menu that will list spaces for a given Team Label. You can further narrow this down alphabetically (spaces with names that start with A-M). It will only show spaces that are viewable to Anonymous users.
This is best used in the header menu by overriding the default Main layout (see Usage). The menus will look and function the same way as the Space and Username menus that are there by default.
Usage
{spacelist:label|title|begin alphabet range|end alphabet range}
Because parameters are not named, you should ensure that all preceeding parameters are specified.
| Parameter | Notes |
|---|---|
| label | This is the Team Label associated with the spaces you want to include |
| title | The text that will show up in the pulldown menu |
| begin alphabet range | The first letter of the range of space names to include (i.e. A) |
| end alphabet range | The last letter of the range of space names to include (i.e. Z) |
## CONTENT DIV BEGINS <div id="header"> #quickSearch() #set($globalHelper=$action.getGlobalHelper()) $globalHelper.renderConfluenceMacro("{spacelist:customers|Customers N-Z|N|Z}") $globalHelper.renderConfluenceMacro("{spacelist:customers|Customers A-M|A|M}") $globalHelper.renderConfluenceMacro("{spacelist:department|Department Spaces|A|Z}") <ul id="header-menu-bar" class="ajs-menu-bar"> $!sitemeshPage.getProperty("page.browse-menu") #menuMacros_renderUserMenu() </ul> $!sitemeshPage.getProperty("page.breadcrumbs") </div>
The key lines are:
#set($globalHelper=$action.getGlobalHelper())
$globalHelper.renderConfluenceMacro("{spacelist:customers|Customers N-Z|N|Z}")
$globalHelper.renderConfluenceMacro("{spacelist:customers|Customers A-M|A|M}")
$globalHelper.renderConfluenceMacro("{spacelist:department|Department Spaces|A|Z}")
This is rendering 3 pulldown menus to the left of the quicksearch box in the header. The first will list ALL spaces with the 'department' team label. The second will list spaces with the 'customers' team label that begin with the letters A-M, and so on.
Code
| Macro Parameters | Value |
|---|---|
| Name | spacelist |
| Has Body | No (unchecked |
| Output | Wiki Markup |
{html}
<ul id='header-menu-bar' class='ajs-menu-bar'>
<li class="normal ajs-menu-item">
<a id="browse-menu-link" class="browse trigger ajs-menu-title" href="#"><span><span>$param1</span></span></a>
<div class="hidden ajs-drop-down">
<ul class="first section-top-level">
{html}
{sql:dataSource=ConfluenceDS|table=false}
select '<li><a href="http://servername/display/'+sp.spacekey+'/Home" class=""><span>'+sp.spacename+'</span></a></li>'
from spaces sp, label lb, content_label cl, spacepermissions per
where lb.name = '$param0'
and lb.labelid = cl.labelid
and cl.spacekey = sp.spacekey
and sp.spaceid = per.spaceid
and per.permtype = 'VIEWSPACE'
and per.permgroupname is null
and per.permusername is null
and sp.spacename >= '$param2' and sp.spacename <= '$param3'
order by sp.spacename
{sql}
{html}
</ul>
</div>
</li>
</ul>
{html}
Confluence Data Source
This requires a Confluence datasource for the SQL Plugin to function. The datasource is defined in your_install_directory/conf/server.xml and will look something like this (for SQL Server):
<Resource name="jdbc/ConfluenceDS" auth="Container" type="javax.sql.DataSource" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://localhost/confluence" username="<confluence db username>" password="<confluence db password>" maxActive="25" maxIdle="5" maxWait="10000" />

Comments (2)
Apr 22, 2008
Roberto Dominguez says:
Cool stuff! I wonder if some CSS guru could post the required CSS classes to ge...Cool stuff!
I wonder if some CSS guru could post the required CSS classes to get it to work on earlier versions.
Apr 22, 2008
Jeff Branc says:
I had it working with the Suckerfish menu styles in 2.7. However, I've since re...I had it working with the Suckerfish menu styles in 2.7. However, I've since removed that code and no longer have it. Its certainly possible by changing the classnames in the macro and adding a Style block to the top of the Main Layout override.
See A List Apart: Suckerfish Dropdowns for more info.