Post by Jordan Reposter on Sept 5, 2011 22:13:05 GMT -5
Code by Jordan
This script will replace all the boards in a category with an image when viewed by guests.
This can be very useful if you have an RPG board and would like to display an image that illustrates what the category is generally about while including a message stating that the user must log in.
It goes in your main footers and you will need to know your category ID's.
If you don't know your category ID's, an easy way to find them is to go into any board within that category and then click on the category link in the nav bar (Message Board :: Category Name :: Board Name).
Click on the category name, and the ID will be the text in your address bar after the hash sign #.
So for this support forum, the ID for the general section is: support.proboards.com/index.cgi#misc
<script type="text/javascript"><!--
/*
* Log-in Image for Restricted Categories
* Created by Triad
* support.proboards.com
*/
var _cat = [
["categoryID", "imageURL"],
["categoryID", "imageURL"] // No comma
];
if(location.href.match(/\.com(\/|.+cgi(\?|#.+|\?\w+=(home|\w{15}y.+))?)?$/i) && pb_username == "Guest"){
for(var tb = document.getElementsByTagName("table"), a = 1; a < tb.length; a++){
if(tb[a-1].className == "bordercolor" && tb.cellPadding == "4" && tb.rows[0].cells[0].innerHTML.match(/forum\sname/i)){
for(r = 1; r < tb.rows.length; r++){
if(tb.rows[r].cells[0].colSpan == "5" && tb.rows[r].cells[0].firstChild.name){
var id = tb.rows[r].cells[0].firstChild.name;
for(x = 0; x < _cat.length; x++){
if(id == _cat[x][0]){
while(tb.rows[++r] && tb.rows[r].cells[0].colSpan != "5"){
tb.rows[r].style.display = "none";
} r--;
var _img = document.createElement("img");
_img.src = _cat[x][1];
_img.border = 0;
var _row = tb.insertRow(tb.rows[r].rowIndex + 1);
var _cell = _row.insertCell(0);
_cell.colSpan = 5;
_cell.align = "center";
_cell.className = "windowbg";
_cell.appendChild(_img);
}
}
}
}
}
}
}
//--></script>
This script will replace all the boards in a category with an image when viewed by guests.
This can be very useful if you have an RPG board and would like to display an image that illustrates what the category is generally about while including a message stating that the user must log in.
It goes in your main footers and you will need to know your category ID's.
If you don't know your category ID's, an easy way to find them is to go into any board within that category and then click on the category link in the nav bar (Message Board :: Category Name :: Board Name).
Click on the category name, and the ID will be the text in your address bar after the hash sign #.
So for this support forum, the ID for the general section is: support.proboards.com/index.cgi#misc
<script type="text/javascript"><!--
/*
* Log-in Image for Restricted Categories
* Created by Triad
* support.proboards.com
*/
var _cat = [
["categoryID", "imageURL"],
["categoryID", "imageURL"] // No comma
];
if(location.href.match(/\.com(\/|.+cgi(\?|#.+|\?\w+=(home|\w{15}y.+))?)?$/i) && pb_username == "Guest"){
for(var tb = document.getElementsByTagName("table"), a = 1; a < tb.length; a++){
if(tb[a-1].className == "bordercolor" && tb.cellPadding == "4" && tb.rows[0].cells[0].innerHTML.match(/forum\sname/i)){
for(r = 1; r < tb.rows.length; r++){
if(tb.rows[r].cells[0].colSpan == "5" && tb.rows[r].cells[0].firstChild.name){
var id = tb.rows[r].cells[0].firstChild.name;
for(x = 0; x < _cat.length; x++){
if(id == _cat[x][0]){
while(tb.rows[++r] && tb.rows[r].cells[0].colSpan != "5"){
tb.rows[r].style.display = "none";
} r--;
var _img = document.createElement("img");
_img.src = _cat[x][1];
_img.border = 0;
var _row = tb.insertRow(tb.rows[r].rowIndex + 1);
var _cell = _row.insertCell(0);
_cell.colSpan = 5;
_cell.align = "center";
_cell.className = "windowbg";
_cell.appendChild(_img);
}
}
}
}
}
}
}
//--></script>