Often pages in plugin have hierarhical structure, so if you for example have 2 pages -
Departments
and Edit Department
, it's preferred that your visotors may navigate fast within these pages. The goal may be achived with a help of top navigation bar, but unfortunatelly confluence only provides backlink to Dashboard
:But what you really prefer is:
The idea is to create your own
breadcrumbs
content tag.breadcrumbs.vm
in your departments
directory:#requireResource("confluence.web.resources:yui-core")
#requireResource("confluence.web.resources:ajs")
#requireResource("confluence.web.resources:breadcrumbs")
<content tag="breadcrumbs">
<ol id="breadcrumbs">
<li><span>#dashboardlink ()</span></li>
<li>></li>
<li><span><a href="$req.contextPath/
admin/departments/observe.action ">Departments</a>
</span></li>
<li>></li>
<li><span>Edit Department</span></li>
</ol>
</content>
...
#parse
("/templates/userinfo/departments/breadcrumbs.vm")
</body>
</html>
breadcrumbs.vm
looks like this:#requireResource("confluence.web.resources:yui-core")
#requireResource("confluence.web.resources:ajs")
#requireResource("confluence.web.resources:breadcrumbs")
<content tag="breadcrumbs">
<ol id="breadcrumbs">
<li><span>#dashboardlink () </span></li>
<li>></li>
#set ($parentClass = $action.getParentClass())
<li><span><a href="$req.contextPath/admin/
departments/observe.action">
$action.getActionName($parentClass.getName())</a>
</span></li>
<li>></li>
<li><span>
$action.getActionName($action.getClass().getName())
</span></li>
</ol>
</content>
breadcrumbs
tag uses action's static function to get parent:public class EditDepartment
extends ConfluenceActionSupport {
...
public static Class<?> getParentClass() {
return ViewDepartments.class;
}
...
}
$action.getActionName($action.getClass().getName())
Of course class names must be defined in i18n properties:
userinfo.departments.action.ViewDepartments.action.name=
Departments
userinfo.departments.action.EditDepartment.action.name=
Edit department
There are lots of things you can do here, make universal code for any page in your plugin, multi level navigations etc!