Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify Confluence to allow duplicate page titles [closed]

Tags:

confluence

I'm using Confluence for documentation, both end user documentation and internal development documentation.

The problem with Confluence is that it doesn't allow duplicate page titles, since the URL consists of only the title and not the whole tree structure.

Is there any way to alter this behaviour?

There is a plugin which does this, and much more. The "much more" part is the problem, because that plug-in is quite expensive, especially if only one of many features will be used (https://marketplace.atlassian.com/plugins/com.k15t.scroll.scroll-versions).

like image 540
Frazer Avatar asked Jan 09 '14 12:01

Frazer


People also ask

How do I duplicate a page in confluence?

If you need to duplicate the content of a page, the easiest way is to copy the page. When you copy a page, Confluence will rename the page Copy of [originalPageName] by default, as pages in a space must have unique names, but you can change this while editing. You can keep the same name if you're moving the page to a different space.

Can I re-use page titles in confluence?

You are now able to create pages that have the same title as previously created pages. This makes it possible to form a common page structure. During a regular Confluence view of the page, the prefix will be hidden. Now you are able to re-use page titles and therefore create standardised page structures.

How do I change the name of a page in confluence?

When you copy a page, Confluence will rename the page Copy of [originalPageName] by default, as pages in a space must have unique names, but you can change this while editing. You can keep the same name if you're moving the page to a different space. To copy a page Go to a page in the space, and click ••• > Copy.

What can you do with confluence?

Keep code reviews, requirements, release notes and more in Confluence, where they are organised in one place. Allows the creation of pages with the same title within a space. Re-use page titles to create standardised page structures


2 Answers

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

like image 115
Patrick Schuh Avatar answered Dec 31 '22 14:12

Patrick Schuh


I realize this is a bit late, but for anyone else looking for this, my solution doesn't require any javascript trickery or special plugins, just an invisible ascii code.

I add ASCII character 255 to the end of my title (or more than one if needed). It appears as whitespace so it doesn't show up in the title. This is only a valid option if you don't care to have the title as part of the URL as Confluence will link to the page by pageId (i.e. https://confluence.yourcompany.com/pages/viewpage.action?pageId=44335161).

If you don't know how to do an ASCII code, just hold down the Alt key while typing 255 on the number pad (or any other ASCII code).

like image 20
zythra Avatar answered Dec 31 '22 15:12

zythra