We had the same issue when adding "virtual empoyee folders" to our wiki. We wanted to biuld the following page structure:
Employee 1
Personal Data
Contract Data
Training
...
Employee 2
Personal Data
Contract Data
Training
...
Employee X
Personal Data
Contract Data
Training
...
We solved it with dirty but very effective workaround: first we made the page names unique by adding employee-specific prefixes:
Employee 1
Employee 1 - Personal Data
Employee 1 - Contract Data
Employee 1 - Training
...
Employee 2
Employee 2 - Personal Data
Employee 2 - Contract Data
Employee 2 - Training
...
Employee X
Employee X - Personal Data
Employee X - Contract Data
Employee X - Training
...
The we defined our own "tag" to mark the part of the page title that should not appear in the confluence frontend:
Employee 1
[hide]Employee 1 - [/hide]Personal Data
[hide]Employee 1 - [/hide]Contract Data
[hide]Employee 1 - [/hide]Training
...
Employee 2
[hide]Employee 2 - [/hide]Personal Data
[hide]Employee 2 - [/hide]Contract Data
[hide]Employee 2 - [/hide]Training
...
Employee X
[hide]Employee X - [/hide]Personal Data
[hide]Employee X - [/hide]Contract Data
[hide]Employee X - [/hide]Training
...
The rest is done by a little JavaScript-Magic, that is embedded via Confluence Admin > Custom HTML:
<script>(function() {
var expr = /\[hide\].*?\[\/hide\]/g,
blacklist = ['textarea', 'form', 'pre', 'script', 'style'];
$(document)
.ajaxSuccess(hideTextParts)
.on('ready', hideTextParts);
function isChildOfBlacklistedTag(node) {
while(node = node.parentNode) {
if (node.nodeType === Node.ELEMENT_NODE && blacklist.indexOf(node.nodeName.toLowerCase()) > -1) {
return true;
}
}
return false;
}
function hideTextParts() {
var root = document,
walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false),
node;
while (node = walker.nextNode()) {
console.info(node.parentNode);
if (expr.test(node.textContent) && !isChildOfBlacklistedTag(node)) {
node.textContent = node.textContent.replace(expr, " ");
}
};
}
})();
</script>
The blacklist ensures that the "tag" is not hidden where you need them to be shown. For example in the title field ofthe editing screen of a page and within the CSS-editing field in the space administration. You may want to extend to