Activate and customize “Table of contents” macro in IBM Connections Wiki

Created:
Last Update:

Author: Christoph Stoettner
Read in about 3 min · 520 words

Notetaking

Photo by David Travis | Unsplash

I have read about a new function in IBM Connections Wiki, which I missed until now. A new macro to create a table of contents within a wiki page.

The activation of this macro is documented here: Wikis configuration properties

wikimacros.enabled

Specifies whether macros are enabled in Wikis. You can use macros to automate common tasks, such as generating a table of contents in a wiki page. The default value of this parameter is false. To enable macros, set the value to true. When enabled, macros are available from the Macros menu in the editor toolbar.

Documentation

I’m a little confused (the config option should be editor.wikimacros.enabled).

wikis-config.xml:

 <editor>
      <wikitexttab enabled="true" />
      <wikimacros enabled="true" /> <!-- add this line -->
 </editor>

After checking in the configuration file and restart connections I got a new button in my wikis’ editor:

Macro for Table of Contents

Quite cool, but the macro only generate headings with format h2, h3 and h4 to the TOC. The Richtext editor provides headings h1-h4. I want to change this behavior, that h1 will be added to TOC too.

I found a great article on adding templates to CKEditor from Rob Novak , there he describes how you can customize the CKEditor of wikis. I used the paths mentioned in this article to customize the TOC behavior.

Extract toc.js

You can find the needed file com.ibm.lconn.wikis.web.resources_3.5.0.20130627-1601.jar in your shared directory, e.g. /opt/IBM/Connections/data/shared/provision/webresources. I extracted it to /tmp:

unzip -d /tmp/ckeditor /opt/IBM/Connections/data/shared/provision/webresources/com.ibm.lconn.wikis.web.resources_3.5.0.20130627-1601.jar

Create customization path and copy toc.js

mkdir -p /opt/IBM/Connections/data/shared/customization/javascript/lconn/wikis/macros
cp /tmp/ckeditor/resources/macros/toc.js /opt/IBM/Connections/data/shared/customization/javascript/lconn/wikis/macros

Change toc.js

vim /opt/IBM/Connections/data/shared/customization/javascript/lconn/wikis/macros/toc.js

You find the following part:

lconn.wikis.macros.toc = {
//node id sequence for TOC link.
    fragmentSeqn: 1,
    topLevel: 2,
    bottomLevel: 4,
    template: 'Table of Contents:<INSERT-BODY>',

You have to change topLevel and bottomLevel to following:

lconn.wikis.macros.toc = {
//node id sequence for TOC link.
    fragmentSeqn: 1,
    topLevel: 1,
    bottomLevel: 5,
    template: 'Table of Contents:<INSERT-BODY>',

After a new Connections restart my toc got updated with h1 – h5.

Update

Change Styles

If you want to change the default style of your tocs, you can do this in the toc.js file too! I prefer my TOC on the right screen side and with a light grey not yellow background.

I changed:

 style: 'border-radius: 6px; margin: 8px; padding: 4px; display: block; width: 50%;background-color: #ffc;',

To:

 style: 'border-radius: 6px; margin: 8px; padding: 4px; display: block; width: 30%;background-color: #E0E0E0;float:right;padding:10px;margin-left:20px;margin-bottom:20px;',

Now i have a little bit smaller toc with additional space to the content:

Changing the style of your toc

It would be better to define the styles through a CSS file in the customization folder, but I only wanted to test it. When you want to change through a CSS file, then you should remove most of the styles from the line starting with: style:.

Update 2022-07-11

I tested the configuration today with Connections 7.0 and installed CFix.70.2206. Except of the jar name, which is now com.ibm.lconn.wikis.web.resources_3.5.0.20220608-0715.jar, the whole process to enable and customize is still working. After changing wikis-config.xml the Macros > Table Of Contents button appears in all Connections editors (CKEditor, textbox.io and TinyMCE)!

Author
Add a comment
Error
There was an error sending your comment, please try again.
Thank you!
Your comment has been submitted and will be published once it has been approved.

Your email address will not be published. Required fields are marked with *

Suggested Reading
Aaron Burden: Fountain pen and a notebook
The Default Page of Wikis shows some content for our users to offer them better work experience, but in some companies it would be good to change this text or use only one language. Content of this welcome page is set in the default language of the user who creates the wiki. I found the properties File for this text area in {WAS_Root}/profiles/AppSrv01/installedApps/{cellname}/Wikis.ear When you unzip the file share.services.jar, you get the path com/ibm/lconn/share/services/handlers/wiki/nls/ and there the properties-files for wikis (WikiWelcomePageMessages.properties). To change the values for english, you create a file named com.ibm.lconn.share.services.handlers.wiki.nls.WikiWelcomePageMessages.properties in {Connections Shared Directory}/customization/strings/ Here you define:
Created:
Last Update:
Read in about 1 min
Aaron Burden: Fountain pen and a notebook

Wikis in IBM Connections 5.5 have a little bug, because the link (/library instead of /wikis/form/api/library) for images are wrong and so they are not displayed.

Created:
Last Update:
Read in about 2 min
Aaron Burden: Fountain pen and a notebook
Last week i searched a way to send all Connections users an information on important updates, which should be configurable and uses cookies to hide it for a specific time. First i had a look at the Greenhouse Announcement Widget which is used within Greenhouse . Quite nice, but i had problems with IE 9 users and the popup appears on each page you open within Connections. So i tried something other. After some searching i found a script of Ollie Phillips which is originally used to inform users about Cookie usage on the site. Ollie published the cookiesDirective.js under the MIT License.
Created:
Last Update:
Read in about 2 min