Post by Scorpian on Nov 8, 2006 14:42:30 GMT -8
Alright, this code is a work of art. It's a category splitter that will only split where & when you want it to. Wait, so how? Well, first things first, here's the code:
That code goes in your main footers. I've defined most of the editing for you. For the headImg variable, say 'yes' if you want a head image ('no' if you don't), and then add the url next to it. The same goes for the baseImg variable. Note that these are both optional, and are not required if you said 'no' to them.
Next, we have the gapDiv variable. That's pretty simple. It's the height of the gap between the categories. Numeric values only. Do not use percents or put 'px' after the number.
The ids variable is where it gets confusing. This is a list of the ids of the categories that you want to start a new category.
Note: To get a category id, go to your admin panel, and click Reorder categories. The list of ids shown is the id of the categories going from top to bottom.
Anyways, when adding a new id, be sure to put it between quotes, and add a comma after every one except for the last one.
Example: ids = ['category1','category2','category3','category4'];
Enjoy this code. If you're confused about the code at all, or if you cannot modify it properly to save your life, feel free to drop me a pm. If you are looking for support on this code, or if you want it modifyed, do not drop me a pm. Post in this thread, or the support board.
This code has been tested and works properly in Firefox 1.5, Internet Explorer 6, and Opera 9.
*Does not work in Chrome - Wormopolis
<script type='text/javascript'>
/* Selective Category Splitter by Scorpian
http://roddyinnovations.com/ */
/*\|===( Edit These )===|\*/
var headImg = ['yes','url_to_head_image']; // Turn on head image? url to head image.
var baseImg = ['yes','url_to_base_image']; // Turn on base image? url to base image.
var gapHeight = '30'; // Height of gap between categories.
var ids = ['general','category2']; // Ids of categories to start new split at.
/*\|===( Do Not Edit )===|\*/
var riTable = document.getElementsByTagName('table');
var headDiv = document.createElement('div');
with(headDiv){
align = 'center';
appendChild(new Image());
firstChild.src = headImg[1];
}
var baseDiv = document.createElement('div');
with(baseDiv){
align = 'center';
appendChild(new Image());
firstChild.src = baseImg[1];
}
var cenTab = document.createElement('table');
with(cenTab){
cellSpacing = 1;
cellPadding = 4;
border = 0;
align = 'center';
className = 'bordercolor';
appendChild(document.createElement('tbody'));
}
var gapDiv = document.createElement('div');
gapDiv.style.height = gapHeight + 'px';
var tF = document.createDocumentFragment();
var start = true;
if(location.href.match(/action=(home|logout)$/i) || !location.href.match(/(action|board)=/i)){
for(a=0; a<riTable.length; a++){
if(riTable[a].cellSpacing == 1 && riTable[a].cellPadding == 4 && riTable[a].rows[0].cells[0].firstChild.firstChild && riTable[a].rows[0].cells[0].firstChild.firstChild.innerHTML == 'Forum Name'){
riTable[a-1].style.backgroundColor = 'transparent';
for(b=1; b<riTable[a].rows.length; b++){
if(riTable[a].rows[b].cells[0].className == 'catbg' && riTable[a].rows[b].cells[0].align != 'right'){
var spt = false;
for(c in ids) if(start || ids[c] == riTable[a].rows[b].cells[0].getElementsByTagName('a')[0].name) spt = true;
if(start || spt){
if(headImg[0] == 'yes') tF.appendChild(headDiv.cloneNode(true));
tF.appendChild(cenTab.cloneNode(true));
var tB = tF.lastChild.firstChild;
if(baseImg[0] == 'yes') tF.appendChild(baseDiv.cloneNode(true));
tB.appendChild(riTable[a].rows[0].cloneNode(true));
}
tB.appendChild(riTable[a].rows[b].cloneNode(true));
start = false;
}
if(riTable[a].rows[b].cells[0].className == 'windowbg'){
tB.appendChild(riTable[a].rows[b].cloneNode(true));
if(riTable[a].rows[b+1] && riTable[a].rows[b+1].cells[0].className == 'catbg' && riTable[a].rows[b+1].cells[0].align != 'right' && spt){
tF.appendChild(gapDiv.cloneNode(true));
}
}
}
riTable[a].parentNode.replaceChild(tF, riTable[a]);
break;
}
}
}
</script>
That code goes in your main footers. I've defined most of the editing for you. For the headImg variable, say 'yes' if you want a head image ('no' if you don't), and then add the url next to it. The same goes for the baseImg variable. Note that these are both optional, and are not required if you said 'no' to them.
Next, we have the gapDiv variable. That's pretty simple. It's the height of the gap between the categories. Numeric values only. Do not use percents or put 'px' after the number.
The ids variable is where it gets confusing. This is a list of the ids of the categories that you want to start a new category.
Note: To get a category id, go to your admin panel, and click Reorder categories. The list of ids shown is the id of the categories going from top to bottom.
Anyways, when adding a new id, be sure to put it between quotes, and add a comma after every one except for the last one.
Example: ids = ['category1','category2','category3','category4'];
Enjoy this code. If you're confused about the code at all, or if you cannot modify it properly to save your life, feel free to drop me a pm. If you are looking for support on this code, or if you want it modifyed, do not drop me a pm. Post in this thread, or the support board.
This code has been tested and works properly in Firefox 1.5, Internet Explorer 6, and Opera 9.
*Does not work in Chrome - Wormopolis