Create groups of topics inside a forum. (Web portal)

We are using some forums as a knowledge base. It's forces to group some topics to similar sections. There are "category" function in Zendesk for combining forums. But now you cannot group topics inside a forum.

I developed a script for widget. This widget will add an ability to grouping inside a forum (see a screenshot http://habrastorage.org/storage2/61d/6a5/993/61d6a59937a5186b4b7e136664043cbc.jpg).

How does it work.

  1. You change name of topic from "Topic name" to "Group name :: Topic name". Where "::" is a splitter.
  2. Create Global Javascript widget with script (at the bottom of page or at Pastebin http://pastebin.com/f2CTCnrP)
  3. When you navigate to forum you'll see a groups.

Algoritm of the code:

1. Get all topics from page

2. Iterate each of topic and looking for splitter

3. Split topic name to group name and topic caption.

4. Try to found existing group name. If yes move the topic to group. Else create new group node

This script is strongly depends on Zendesk's markup. And I hope that it will not changed in future =)

// Get current url

var s_url=window.location.pathname;

var s_urlparts = s_url.split('/');

var s_section = s_urlparts[1];

// Run if we in the "forums" section

if (s_section=='forums')


// Group node HTML

var group_node_start = '<div class="item "><h1 class="fade\_truncation\_outer"><div class="fade\_truncation\_inner"></div><span class="group\_node" style="font-size:14pt">'

var group_node_finish= '</span></h1></div><br/>';

// Get all topics from page

var topic_link = $j("div.item div h1 span a");

var split_divider = "::"; // splitter

$j.each(topic_link, function ()


// for each topic in collection

var title = $j(this).attr('title'); // get topic title

var title_splitted = title.split(split_divider); // split topic title

if (title_splitted.length>1)


// if splitted

// Get group name

var group_name=title_splitted[0].trim();

// Get topic name

var topic_name=title_splitted[1].trim();

// Set topic name without group name



// Get parent of item

var found_item = $j(this).parent().parent().parent().parent();

// Try to get existing groups

var group_node = $j('span.group_node:contains("'+group_name+'")');

if (group_node.length)


// Great. We found group. Move item to this group.

group_node.append("<div class='item '>"+found_item.html()+"</div>");





// Not found. Ok. Create new and move item to it.

var root_node=$j("div#search-result");


$j('span.group_node:contains("'+group_name+'")').append("<div class='item '>"+found_item.html()+"</div>");





// remove doubles at bottomline

$j.each($j("span.group_node"), function ()






Please sign in to leave a comment.