Previous Thread
Next Thread
Print Thread
Rate Thread




and directly below that, add:





here we write the way that our new variable will be seen in CP's 'style settings' section. notice VALUE="$cellpadding". i'm assuming that cgi is case-sensitive. so you should stay consistent -- if you write $cellPadding then always write it as $cellPadding and not $Cellpadding or anything else.

we'll come back to this file later, but for now, we're done with it. save it and close it.
----------------------------------------------------


-(5)-----cpanel3.cgi--------------------------------
find:





directly below that, add:





which does the same as in step (4).

next, find:

print FORSTYL ('$TextSize = "' . "$in{'TextSize'}" . '"' . ";n");

directly below it, add:

print FORSTYL ('$cellpadding = "' . "$in{'cellpadding'}" . '"' . ";n");

this will write the cellpadding variable to forumstyles.file which holds the style values of a forum.

next, find:

if ($Name eq "TextSize") {
$TextSize = $Value;
}


directly below it, add:

if ($Name eq "cellpadding") {
$cellpadding = $Value;
}


then, find:

print FORSTYL ('$TextSize = "' . "$TextSize" . '"' . ";n");

directly below it, add:

print FORSTYL ('$cellpadding = "' . "$cellpadding" . '"' . ";n");

then, find:

print FORSTYL ('$TextSize = "' . "$TextSize" . '"' . ";n");

and directly below that, add:

print FORSTYL ('$cellpadding = "' . "$cellpadding" . '"' . ";n");

basically, what we've done is setup 'cellpadding' as a style variable, made it present in the 'style settings' section, given it a default value and we've also made sure that it gets tossed into the appropriate style settings files.
----------------------------------------------------------


-(6)---that's it!-----------------------------------------
that's it? well, partly. now that we've declared it as a variable and given it default values, we just need to replace every existence of cellpadding's original instance with a variable instance. that is to say, everywhere in the cgi/pl that contains <....cellpadding="X"...> where X is a number, we replace X with $cellpadding. basically, this just puts the value that we give to cellpadding (in the control panel) in place of every instance of $cellpadding. so the following code:

Joined: Sep 2000
Posts: 5
sc
Offline
Junior Member
Junior Member
Offline
Joined: Sep 2000
Posts: 5
---------------------------------------------------
how to add your own style-hacks to 'style settings'
---------------------------------------------------

-(0)-------------------------------------------------
i come from a design (as opposed to programming) perspective, and i've always thought that UBB was pathetic in terms of gui interface customization. initially, i simply hard-scripted values in the cgi/pl's to get the look i wanted. however, after updating my site with a few hacks i became more adventurous (thanks ubbdev.com!) and set out to add the ability to set variable values for specific style settings via the control panel. for example, allowing one to change the cellpadding value for all tables .

i believe the process of adding this capability for any variable such as cellspacing or cellpadding (for example) is the same, and hence would like to make this a guide for showing you how to add your own 'style settings' variable hacks as it can be a tedious (albeit simple) process. so instead of going through and showing how to give you the capability to control two different types of cellspacing variables and every other possible variable (overkill), i thought it'd be more useful to
explain the process so that you could then add in whatever style hack for the style-settings you wanted.

we'll explain this by going through an example of setting up a field in the CP's (control panel's) 'style settings' which allows you to specify a Cell Padding size for ALL tables in UBB. generally, this is fixed at "4", but with this guide you'll be able to set the 'cellpadding' size from 0-9 or whatever the (or your) limit happens to be. you'll also, hopefully, have an understanding of how to add your own variables to the control panel.

if this sort of guide has already been done, sorry. [Linked Image]

thanks to everyone who's made a hack and documented it nicely. nothing worse than a badly documented hack, eh? hopefully this one isn't too bad.

no doubt there's bound to be mistakes. no guarantees, blah blah blah your own doing gets you blah blah blah...

also, i'm sure this is quite a laughable addition for all you hack pro's, but i've only been working with cgi for the last 2 hours, so it's quite an achievement for me [Linked Image] bear with my poor understanding. don't be too upset because i call it $cellpadding and not $CellPadding. hopefully this can be of use to someone as many of your hacks have been of use to me. thanks!
----------------------------------------------------


-(1)---what is cellpadding?--------------------------
i don't have the standard definition, but to my understanding, cellpadding is the padding, in pixels, between the outside of a table and it's contents. generally, a cellpadding value of 1 or 2 gives enough space for the eye to distinguish a table from it's contents (text, perhaps).
----------------------------------------------------


-(2)---let's begin, backup!-------------------------
personally, i think the first thing you should always do before installing any hack is backing up your current cgi/pl files. here are the files you will be editing, which i recommend backing up just in case there is a foul up in which case you can just copy over the screwed up copy.

announce.cgi
archive.cgi
cpanel.cgi
cpanel2.cgi
cpanel3.cgi
cpanel4.cgi
edit.cgi
forumdisplay.cgi
postings.cgi
register_lib.pl
search.cgi
ubb_library.pl
ubb_library2.pl
ubbmail.cgi
ubbmisc.cgi
Ultimate.cgi

don't get too flustered if that looks like too much. 90% of the editing is just find/replace. also, if you don't have some of these cgi's, it's possible that they're from a hack i've installed. assume that if you don't have it, it's ok. also, if you're quite content with the way the cellpadding is set in most areas, then obviously you only have to edit the parts that you do want to have CP-control over.

secondly, it might be a good idea to go into 'general settings' and turn UBB off, as viewers might see errors (ise 500) if you are working on/uploading the hack while they are trying to read. don't worry, it shouldn't take more than 10 minutes.
----------------------------------------------------


-(3)--------ok, for real, let's start---------------
the first thing we have to do is decide what variable we want to make customizeable. in our example, we're going to make it the 'cellpadding' variable (see above if you don't know what cellpadding is).

no matter what variable/html tag you decide on, cpanel.cgi and cpanel3.cgi are the important cgi's where you should start and define your variables and their default values as well as their appearance in your control panels' 'style settings' section.
----------------------------------------------------


-(4)-------cpanel.cgi-------------------------------
first, find:

if ($TextSize eq "") {
$TextSize = "2";
}


directly below that, add:

if ($cellpadding eq "") {
$cellpadding = "0";
}


here you are setting the default value of our variable cellpadding to be "0". which will yield a result equivalent to <... cellpadding=0...> in a normal html tag.

then, look for:


Text Size
We recommend using size 2... but depending on your font face, you may want to alter this.



Cell Padding
Sets the 'cellpadding' variable in most (if not all) tables. If you use a small Text Size (ie, 1) we recommend a value of 0 or 1 for this setting resulting in a much more compact style.





Text Size
We recommend using size 2... but depending on your font face, you may want to alter this.





Cell Padding
Sets the 'cellpadding' variable in most (all?) tables. If you use a small Text Size (ie, 1) we recommend a value of 0 or 1 for this setting resulting in a much more compact style.
.





is what appears by default. but the whole point of this guide is that we don't want to have to go through every cgi file EVERYTIME we want to change it's value. so we write:



now, $cellpadding will be replaced with whatever value you give it in your control panel.

the tedious part: you have to go through the following files:

announce.cgi
archive.cgi
cpanel.cgi
cpanel2.cgi
cpanel3.cgi
cpanel4.cgi
edit.cgi
forumdisplay.cgi
postings.cgi
register_lib.pl
search.cgi
ubb_library.pl
ubb_library2.pl
ubbmail.cgi
ubbmisc.cgi
Ultimate.cgi

and for every instance of "cellpadding=X" (without the quotes) you replace the X with $cellpadding

you should be able to do a simple Find/Replace which will speed up the process tremendously. by default, ubb gives cellpadding a value of 4 in most instances. so, if you do a find for 'cellpadding="4"' and replace it with 'cellpadding="$cellpadding"' then you will get most of the work done. however, there might be some instances where cellpadding=0 or other values, depending on your setup. at this point, it's best to do things manually (find cellpadding) and everywhere that the word 'cellpadding' appears in <....>, make the appropriate changes as shown above.

after this, you set your desired values for your new variables in the style settings. and then, you have to change the values in EACH forum as well or else the changes won't take place. don't forget to update threads as well.
-----------------------------------------------------------


-(7)---other variables-------------------------------------
as i stated originally, this process isn't just useful for controlling cellpadding globally -- you can also do the same for various instances of 'border' or 'cellspacing' or 'align' or any other tag you want. generally, ubb sticks to 1-2 values for most tags. for example, by default, cellpadding is almost always either "0" or "4". additionally, cellspacing is almost always "1" or "0". if you want more control, you can, for example, create more variables for more strict control -- $cellspacingA and $cellspacingB. where different parts of your bulletin board have different cellspacing values, or borders, or alignment, or whatever you wish!

steps 2-5 are the most important steps that you would go through to setup any new variables. you have to define it, give it a default value, and make sure that it gets listed in the appropriate styles files.
--------------------------------------------------thanks--


------------------
Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)