Admin
09-16-2001, 10:00 PM
This hack adds a yes/no option for forums, to select whether you want to display that forum (or category) on the main page.
I added a "sanity check", so you can't hide forums that have no parent (because then you won't be able to access any of its sub-forums).
I'll get a demo in a few minutes.
Demo::
https://vborg.vbsupport.ru/attachment.php?s=&postid=172718
Installation::
Run this query:
ALTER TABLE forum ADD showonhome SMALLINT(6) DEFAULT '1' not null AFTER allowicons
In forum.php (admin folder) replace
makeyesnocode("Count posts made in this forum towards user post counts?","countposts",1);
with
makeyesnocode("Count posts made in this forum towards user post counts?","countposts",1);
maketableheader("Other Options");
makeyesnocode("Display this forum on main page","showonhome",1);
Still in forum.php, replace
makeyesnocode("Count posts made in this forum towards user post counts?","countposts",$forum[countposts]);
with
makeyesnocode("Count posts made in this forum towards user post counts?","countposts",$forum[countposts]);
maketableheader("Other Options");
makeyesnocode("Display this forum on main page","showonhome",$forum[showonhome]);
Still in forum.php, replace
moderatenew,allowhtml,allowbbcode,allowimages,allo wsmilies,allowicons,
with
moderatenew,allowhtml,allowbbcode,allowimages,allo wsmilies,allowicons,showonhome,
Still in forum.php, replace
'$moderatenew','$aallowhtmlcode','$aallowbbcode',' $aallowimgcode','$aallowsmilies','$aallowicons',
with
'$moderatenew','$aallowhtmlcode','$aallowbbcode',' $aallowimgcode','$aallowsmilies','$aallowicons','$ showonhome',
Still in forum.php, replace
allowimages='$aallowimgcode', allowsmilies='$aallowsmilies', allowicons='$aallowicons',
with
allowimages='$aallowimgcode', allowsmilies='$aallowsmilies', allowicons='$aallowicons', showonhome='$showonhome',
Still in forum.php, replace
// SANITY CHECK (prevent invalid nesting)
if ($parentid==$forumid) {
echo "<b>ERROR:</b> You can't parent a forum to itself!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
$foruminfo = $DB_site->query_first("SELECT forumid,title,parentlist FROM forum WHERE forumid='$parentid'");
$parents = explode(",", $foruminfo[parentlist]);
while (list(,$val) = each($parents)) {
if ($val==$forumid) {
echo "<b>ERROR:</b> You can't parent a forum to one of its own children!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
}
// end Sanity check
with
// SANITY CHECK (prevent invalid nesting)
if ($parentid==$forumid) {
echo "<b>ERROR:</b> You can't parent a forum to itself!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
$foruminfo = $DB_site->query_first("SELECT forumid,title,parentlist FROM forum WHERE forumid='$parentid'");
$parents = explode(",", $foruminfo[parentlist]);
while (list(,$val) = each($parents)) {
if ($val==$forumid) {
echo "<b>ERROR:</b> You can't parent a forum to one of its own children!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
}
if ($parentid==-1 and $showonhome==0) {
echo "<b>ERROR:</b> You can't hide a forum with no parent!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
// end Sanity check
We don'e with forum.php, save and upload.
In index.php (main folder) replace
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
with
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND showonhome=1 AND active=1 ORDER BY parentid,displayorder');
We don'e with index.php, save and upload.
That's it! :)
I added a "sanity check", so you can't hide forums that have no parent (because then you won't be able to access any of its sub-forums).
I'll get a demo in a few minutes.
Demo::
https://vborg.vbsupport.ru/attachment.php?s=&postid=172718
Installation::
Run this query:
ALTER TABLE forum ADD showonhome SMALLINT(6) DEFAULT '1' not null AFTER allowicons
In forum.php (admin folder) replace
makeyesnocode("Count posts made in this forum towards user post counts?","countposts",1);
with
makeyesnocode("Count posts made in this forum towards user post counts?","countposts",1);
maketableheader("Other Options");
makeyesnocode("Display this forum on main page","showonhome",1);
Still in forum.php, replace
makeyesnocode("Count posts made in this forum towards user post counts?","countposts",$forum[countposts]);
with
makeyesnocode("Count posts made in this forum towards user post counts?","countposts",$forum[countposts]);
maketableheader("Other Options");
makeyesnocode("Display this forum on main page","showonhome",$forum[showonhome]);
Still in forum.php, replace
moderatenew,allowhtml,allowbbcode,allowimages,allo wsmilies,allowicons,
with
moderatenew,allowhtml,allowbbcode,allowimages,allo wsmilies,allowicons,showonhome,
Still in forum.php, replace
'$moderatenew','$aallowhtmlcode','$aallowbbcode',' $aallowimgcode','$aallowsmilies','$aallowicons',
with
'$moderatenew','$aallowhtmlcode','$aallowbbcode',' $aallowimgcode','$aallowsmilies','$aallowicons','$ showonhome',
Still in forum.php, replace
allowimages='$aallowimgcode', allowsmilies='$aallowsmilies', allowicons='$aallowicons',
with
allowimages='$aallowimgcode', allowsmilies='$aallowsmilies', allowicons='$aallowicons', showonhome='$showonhome',
Still in forum.php, replace
// SANITY CHECK (prevent invalid nesting)
if ($parentid==$forumid) {
echo "<b>ERROR:</b> You can't parent a forum to itself!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
$foruminfo = $DB_site->query_first("SELECT forumid,title,parentlist FROM forum WHERE forumid='$parentid'");
$parents = explode(",", $foruminfo[parentlist]);
while (list(,$val) = each($parents)) {
if ($val==$forumid) {
echo "<b>ERROR:</b> You can't parent a forum to one of its own children!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
}
// end Sanity check
with
// SANITY CHECK (prevent invalid nesting)
if ($parentid==$forumid) {
echo "<b>ERROR:</b> You can't parent a forum to itself!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
$foruminfo = $DB_site->query_first("SELECT forumid,title,parentlist FROM forum WHERE forumid='$parentid'");
$parents = explode(",", $foruminfo[parentlist]);
while (list(,$val) = each($parents)) {
if ($val==$forumid) {
echo "<b>ERROR:</b> You can't parent a forum to one of its own children!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
}
if ($parentid==-1 and $showonhome==0) {
echo "<b>ERROR:</b> You can't hide a forum with no parent!<br><br>".makelinkcode("Go back","javascript:history.back(1)");
exit;
}
// end Sanity check
We don'e with forum.php, save and upload.
In index.php (main folder) replace
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
with
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND showonhome=1 AND active=1 ORDER BY parentid,displayorder');
We don'e with index.php, save and upload.
That's it! :)