View Full Version : How not to modify templates

09 Mar 2006, 03:39
Okay, I've noticed that almost every hack I install for 3.5 requires template edits, and most aren't necessary. With the new hook system you can avoid most template edits.

Look at the php file that contains the hook you are using and see how it is creating it's output.

A simple example is the many, many postbit template changes hacks require. If you look at the vB_Postbit class in class_postbit.php you will see that the parts of a post are exposed to you quite nicely. If you want to add something after message, for example, just do so:

$this->post['message'] .= 'put something here';

The advantage of this is it doesn't matter what postbit they are using - new or legacy.

By careful consideration almost all template modifications can be avoided. Just my two cents :)

26 Apr 2006, 19:08
You can use str_replace (or similar) to completely avoid template edits too, something like:

$output = str_replace("</body>", $your_output . "</body>", $output);
// ($output is the standard variable for whatever page vB is compiling)

That would put your output before the </body> tag.

The problem with that is search replacing takes time so template edits can be preferable.