View Full Version : [RELEASE] Custom Styles Per Forum!
Yes, its finally here.
No longer will you need to create duplicate templates just to set a few custom colors on the forum level.
I don't have a use myself, but it was heavily requested, so I figured what the heck! Yes Nathan, this will work great with the InfoGrames boards :)
There are nicers ways of going about this than what I did, but this required the least table modification and code changing, so it should be fine.
This was lightly tested on my test board, and all seemed to work well, but no guarentees. I suggest you backup global.php (main directory, not admin) before making any changes.
Here's how it works:
You go to the style page (styles.php) and it brings up a list of all forums. To the right of those forums are numbers, and they all are equal to 0. Those numbers represent the number of custom style settings represented in that specific board. So if you only change the <body> tag, that number will display 1. If you customize it completely, the number will be higher.
Also, since some forums might only require small changes, those fields which you don't specify will use the installation default (what you set in the existing styles section).
Yea, the interface is pretty ugly and the code isn't much better...but its fast, and it works.
Everything else will be improved upon with time, as long as this thread is as popular as Ed's are!
Directions:
execute the following mysql command:
ALTER TABLE replacement ADD forumid SMALLINT (5) DEFAULT '0' not null;
if you don't know how, then create replacementfid.php: (in /forum, or /forum/admin)
<?
require ("global.php");
if (mysql_query("ALTER TABLE replacement ADD forumid SMALLINT (5) DEFAULT '0' not null")) {
print "Success!";
} else {
print "Failed!";
}
?>
open global.php: (in /forum, not /forum/admin)
look for:
// load vars
$vars=$DB_site->query("SELECT * FROM replacement ORDER BY replacementid DESC");
delete up until:
// ###################### Start standarderror #######################
place in that spot:
// ###################### Start dovars #######################
function dovars($vartext,$fid=0) {
// parses replacement vars
global $DB_site;
global $forumid;
global $vars;
// load vars
$cusvars=$DB_site->query("SELECT * FROM replacement where forumid = $forumid ORDER BY replacementid DESC");
$newtext=$vartext;
$DB_site->data_seek(0,$cusvars);
$forumspec = "";
while ($cusvar=$DB_site->fetch_array($cusvars)) {
$newtext=str_replace($cusvar[findword],$cusvar[replaceword],$newtext);
$forumspec .= "and findword != '$cusvar[findword]' ";
}
$vars=$DB_site->query("SELECT * FROM replacement where forumid = 0 $forumspec ORDER BY replacementid DESC");
$DB_site->data_seek(0,$vars);
while ($var=$DB_site->fetch_array($vars)) {
$newtext=str_replace($var[findword],$var[replaceword],$newtext);
}
return $newtext;
}
save and close.
create styles.php: (in /forum/admin, not /forum)
update: it appears, since I'm using replacement variables in the code, that this vBulletin installtion is actually replacing the code on the fly. to get the code for styles.php, please go to the following url:
http://unreal2.net/styles.phps
start forum/admin/styles.php from your web browser
Easy enough? Of course... :)
No demo, since I don't have a use for it, but if Nathan (hint hint) or someone else could put it into use to demonstrate, that'd be great!
[Edited by Stallion on 07-15-2000 at 02:48 AM]
yay ! interesting... i would have use for this but ain't game enough to try it out as i am php illiterate....
anyone trying it, can show a working demo?
It appears that it allows you to set different colors and fonts. What about the bbtitle.jpg? People will want different graphics for each forum.
You can set different bbtitle images and new topic/post reply links through the actual forum options.
I'm not 100% sure, but thats where I remembered seeing it.
how would this hack, effect future upgrades ? would it have to be hacked again ?
If global.php is updated with that version, then yes, it will have to be hacked.
However, its just a small text replacement, so I don't see it being too much of a problem.
Just for the record, I am working on some scripts to "auto-hack" this into your board, as well as providing a global.php (already hacked, but only accessible with your vB username/password). So basically, you login: http://www.unreal2.net/vb, fill in your details, and you can download the hack itself. This way, we're not violating copyright issues but still making it easy to install a hack.
Thanks for this, it's just what I needed.
I've got it installed and running on a test BBS, but for some reason I can't get the <BODY> settings to stick. This allows me to change everything but the BGCOLOR and TEXT params, leaving the vB defaults instead.
Also, in the styles.phps code (from $style = "<body>" thru $style = "</smallfont>") some carats were being used instead of curly braces preventing the display of those elements in the form. I "corrected" those to match the other $style entries, but don't know if that might have made things worse...
I could also just not be using the proper syntax.
Any help would be appreciated.
That vB hack thingy is cool... how did u do it?
illout: thanks for testing, I'll take a look.
JohnM: the same way I did it for UBB, http://www.unreal2.net/ubb :)
Pretty cool, eh?
That UBB link doesn't work :)
And I'm pretty sure I know how to do it actually.
Originally posted by Ed Sullivan
That UBB link doesn't work :)
And I'm pretty sure I know how to do it actually.
Doh, its http://www.unreal2.net/auth
But Ed, we must keep it secret for the vB hackers site we're launching...exclusive technoligy is a Good Thing ;)
:(
How can you validate it when the database isn't on your server? Unless somehow you did an HTTP call and submitted that info to the members area login thingy and checked the response... not sure if I explained that right...
[Edited by JohnM on 07-16-2000 at 01:02 PM]
You've got the right idea... ;)
Stallion,
Your validation script doesn't work for me. However, I've got a leased license - maybe there's another value returned based on license type?
I'd like to be able to DL this file and compare it to the version I've got to potentially eliminate another source of error.
Anyone else try this hack yet?
OK you PHP people, how do you do an HTTP POST call in PHP?
[Edited by JohnM on 07-16-2000 at 03:07 PM]
All right, I've got the hack working now (I had a typo in global.php causing problems). Individual board settings seem to work, but now I'm getting the following error on the main page:
Warning: Offset 0 is invalid for MySQL result index 63 in admin/db_mysql.php on line 108
Every board (except the test board where I've modified via styles.php) shows a variation of that message (different index points.
If anyone has any ideas, I'd love to hear 'em.
Thanks.
Can someone please help with this hack? I installed it and while it has alot of bugs, it also has alot of potential. Could someone that knows php well offer some help with this, I really need this hack.
Goldenboy
Apparently there is something wrong with this hacked function, it causes errors on pages that call it directly, ie. smilies page, index page (when categories only is set), faq etc...
// ###################### Start dovars #######################
function dovars($vartext,$fid=0) {
// parses replacement vars
global $DB_site;
global $forumid;
global $vars;
// load vars
$cusvars=$DB_site->query("SELECT * FROM replacement where forumid = $forumid ORDER BY replacementid DESC");
$newtext=$vartext;
$DB_site->data_seek(0,$cusvars);
$forumspec = "";
while ($cusvar=$DB_site->fetch_array($cusvars)) {
$newtext=str_replace($cusvar[findword],$cusvar[replaceword],$newtext);
$forumspec .= "and findword != '$cusvar[findword]' ";
}
$vars=$DB_site->query("SELECT * FROM replacement where forumid = 0 $forumspec ORDER BY replacementid DESC");
$DB_site->data_seek(0,$vars);
while ($var=$DB_site->fetch_array($vars)) {
$newtext=str_replace($var[findword],$var[replaceword],$newtext);
}
return $newtext;
}
I've tried rewriting this, but I'm not making much progress.
taking out the following line solves the problem illout mentioned.
$DB_site->data_seek(0,$cusvars);
but I'm not sure if thats a vital piece of code or not.
ANY help with this would be much appreciated.
Goldenboy
Stallion,
You validation script dont work for me..!!
George
The authentication page is currently broken, I'll fix it when I have some time. There's no real secret goodies inside it, it was more of a tech test ;-)
And about the above hack, I'll take a look at the problems later tonight (but I'm currently busy with some work, atm(.
Stay tuned.
I would really appreciate that, thanks. Please keep me posted on any progress you make. To the people who plan on installing this hack, I strongly recommend doing it on a test board, in its current state it can easily whack your vb.
Goldenboy
darn. And I was just about to leap. :)
Originally posted by Stallion
The authentication page is currently broken, I'll fix it when I have some time. There's no real secret goodies inside it, it was more of a tech test ;-)
And about the above hack, I'll take a look at the problems later tonight (but I'm currently busy with some work, atm(.
Stay tuned.
Talk to Ed, he emulated your script
Speaking of which so did I (with some help from ed for the members area stuff) but I'm sure his is alot better, seeing as how I'm new to PHP and all
Has anyone been able to fix this function yet? I'd really like to deploy this hack, but can't.
TIA,
Illout.
Yes, its finally updated. :-)
Directions:
execute the following mysql command: (if you've already done this in previous installation attempts, don't do it again!)
ALTER TABLE replacement ADD forumid SMALLINT (5) DEFAULT '0' not null;
if you don't know how, then create replacementfid.php: (in /forum, or /forum/admin)
<?
require ("global.php");
if (mysql_query("ALTER TABLE replacement ADD forumid SMALLINT (5) DEFAULT '0' not null")) {
print "Success!";
} else {
print "Failed!";
}
?>
open global.php: (in /forum, not /forum/admin)
look for:
// load vars
$vars=$DB_site->query("SELECT * FROM replacement ORDER BY replacementid DESC");
delete up until:
// ###################### Start standarderror #######################
place in that spot:
// ###################### Start dovars #######################
function dovars($vartext,$fid=0) {
// parses replacement vars
global $DB_site;
global $forumid;
global $vars;
$forumspec = "";
if ($forumid) {
$cusvars=$DB_site->query("SELECT * FROM replacement where forumid = $forumid ORDER BY replacementid DESC");
$newtext=$vartext;
while ($cusvar=$DB_site->fetch_array($cusvars)) {
$newtext=str_replace($cusvar[findword],$cusvar[replaceword],$newtext);
$forumspec .= "and findword != '$cusvar[findword]' ";
}
}
$replacevars=$DB_site->query("SELECT * FROM replacement where forumid = 0 $forumspec ORDER BY replacementid DESC");
$DB_site->data_seek(0,$replacevars);
while ($var=$DB_site->fetch_array($replacevars)) {
$newtext=str_replace($var[findword],$var[replaceword],$newtext);
}
return $newtext;
}
save and close.
create styles.php: (in /forum/admin, not /forum)
update: it appears, since I'm using replacement variables in the code, that this vBulletin installtion is actually replacing the code on the fly. to get the code for styles.php, please go to the following url:
http://unreal2.net/styles.phps (make sure to refresh, this code has been updated)
new step - open up forum/index.php and look for:
eval("echo dovars(\"".gettemplate("forumhome")."\");");
directly above it, place:
$forumid = "";
start forum/admin/styles.php from your web browser
This _should_ fix all of the problems people were having :)
Please try it out and let me know! Thanks,
[Edited by Stallion on 07-30-2000 at 08:48 PM]
Stallion:
I've got it in and working. All forums can have custom styles and that works fine. However, I'm still getting the following error on the main forum page, and any page (member list, search, etc.) that is not a specific forum listed in styles.php - I CAN access those pages now, which is a major improvement over the last version :)
The error is:
Warning: 0 is not a MySQL result index in admin/db_mysql.php on line 82
It doesn't seem to effect operation at all, but I'm curious as to whether or not it's fixable.
Thanks. I really appreciate all the time and effort that's gone into this hack.
I updated the dovars section (where you replaced existing global.php code), so you can try that code. The weird thing is, it doesn't seem to work locally, but it *should*.
I don't get the error you reported, so the new update just might work.
Yeah, I'm using the new code. It definitely works better than before. One other issue that's cropped up is that running a search returns results using a variety of color schemes. It's pretty funny actually.
Anyway, the hack worked well enough for me to launch the new software. It's still got some rough edges, but I'm working on them.
If you want to see the errors stop by http://illout.com/forums/ the search thing is pretty funny.
Once again, thanks for the hack. It's a lifesaver when you've got lots of forums with custom l&f's.
[Edited by illout on 07-31-2000 at 12:08 PM]
To get rid of the error I was getting, I made the following change to the hack above:
Instead of
$forumid = "";
I changed it to
$forumid = "1";
and that did it for the index page. However, I'm having to prepend that line before every echo statement in member.php, memberlist.php, search.php, etc.
Anyone know a way I can do this globally?
Any help appreciated.
can someone say me where i can find the styles.php?
the link above don't work :(
The only link I see in this thread for styles.php is broken. Can somebody post a new link please?
Does anybody have this hack installed? I have asked repeatedly for the styles.php file and have got nothing so far. I am hoping and praying that somebody who has the hack installed might be kind enough to provide me the file.
PLEASE!! That is, unless this hack just does not work. A reply would be nice tho.
I will keep bumping this to the top until I get an answer because this hack solves a MAJOR problem with amissing feature in vBulletin. My UBB does not have this problem and this is a major reason why I have not completely switched over yet.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.