vForums Support > Programming & Coding :: Database of Codes/Hacks/Mods :: > Categorized Sub-Boards

Categorized Sub-Boards - Posted By Marc (cr0w) on 22nd Mar 08 at 7:29pm
Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /*
  4. Categorized Sub-Boards by Cr0w
  5. Copyright 2008
  6. Do not repost
  7. */
  8. var sp = []; var brds = new Array(); var cts = new Array(); //Do Not Edit This Line
  9.  
  10. // Categories
  11. cts[0] = "Category 1 Name";
  12. cts[1] = "Category 2 Name";
  13.  
  14. // Board Organization
  15. sp[0] = ["Board ID",category_id];
  16. sp[1] = ["Board ID",category_id];
  17. sp[2] = ["Board ID",category_id];
  18. sp[3] = ["Board ID",category_id];
  19.  
  20. // Category Spacing
  21. var catSpace = 0; // Space you want between categories
  22.  
  23. // No More Edits
  24. if(!location.href.match(/topic/)){
  25. var tr = get('tr','tag');
  26. var td = get('td','tag');
  27. var sb = get('subboards','id');
  28. var n = 0;
  29. var nt = "";
  30. var ntree = get('nav_tree','id');
  31.  
  32. for(t=0;t<tr.length;t++){
  33. if(tr[t].id.match(/^board_(.+?)$/i)){
  34.   for(i=0;i<sp.length;i++){
  35.    if(RegExp.$1==sp[i][0]){
  36.     brds[n] = tr[t].cloneNode(true);
  37.     n++;
  38.    }
  39.   }
  40.   tr[t].style.display = "none";
  41. }
  42. }
  43. for(s=0;s<td.length;s++){
  44. if(td[s].width=="70%" && td[s].innerHTML.match(/Sub\-Board Name/) && td[s+1].width=="22%"){
  45.   td[s].parentNode.parentNode.parentNode.parentNode.style.display = "none";
  46. }
  47. }
  48.  
  49. ntree.style.display = "none";
  50. nt = '<table align="center" width="' + vf_width + '"><tr><td id="nav_tree">' + ntree.innerHTML + '</td></tr></table>';
  51. for(x=0;x<cts.length;x++){
  52. nt += '<table align="center" class="border" cellpadding="2" cellspacing="1" width="' + vf_width + '">';
  53. nt += '<tr><td align="center" class="title1" colspan="5">' + cts[x] + '</td></tr>';
  54. for(q=0;q<brds.length;q++){
  55.   if(sp[q][1]==x){
  56.    nt += '<tr>' + brds[q].innerHTML + '</tr>';
  57.   }
  58. }
  59. nt += '</table>' + ((catSpace > 0) ? '<div style="height: '+catSpace+'px">­</div>' : '');
  60. }
  61. sb.innerHTML = nt;
  62. }
  63. //-->
  64. </script>
 


The above goes in your board footer.

This goes in your board header:

Code:
 
  1. <div id="subboards"></div>
 


Now, to edit:

cts[0] = "Category 1 Name"; - Self explanatory; the name for the first new category.

sp[0] = ["Board ID",category_id];

"Board ID" is the ID for the sub-board you're putting in a category. (Ex: This board's ID is "database")

category_id is the ID number of the category your board is being put in. For example, if you have cts[0] = "Rawr", "Rawr" has an ID of 0.

Note: Make sure the "Board Organization" list is in the same order as your boards appear on the page, otherwise they will not get organized properly.