michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Sun Sep 15, 2002 3:07 pm Post subject: Guidelines to submit hacks |
|
|
1. Use external files if possible.
This means that instead of saying paste this function in b2template.functions.php, you should make an external file with that function, and say save that code as externalfile.php and paste this in b2templates.functions.php: include('b2-include/externalfile.php');.
This way, when the user upgrades to a new version of b2, all she has to do is add the include statement back in b2template.functions.php (and/or any other file where you add code, for that matter).
If you absolutely have to modify existing b2 code, be very clear about what you're modifying and where in the files.
2. Use good PHP.
That's a given. If you started PHP last week, it is better to submit a hack/feature request than try to make a hack and have people complaining that it doesn't work in all possible situations.
Try to make your code readable as much as possible. This means proper indenting and clear variable names.
3. Don't just replace existing b2 files.
For example if you're going to add something to the form in b2edit.form.php, don't submit a modified file and say 'just replace b2edit.form.php with this modified version'. This makes users confused about what's been modified and could leave them with a non-working hack should b2's code be modified to expect new things from b2edit.form.php.
Of course this goes for other files too. If you submit another version of an archives page, don't tell people to replace b2archives.php with it, give it another name.
4. Use existing b2 functions as much as possible.
For example, you don't need to make users fill in their db details in your new hack, just include b2config.php and then use the dbconnect() function to connect to the db.
Look in b2functions.php for functions that could fit your needs. Not only would it speed up your coding, but it would make smaller, more readable files.
If you want to comment on these guidelines or suggest other guidelines to follow, please reply here. |
|