Back to vBulletin 3 Articles

Override Style on Custom Pages
by tyrionlannister 29 Jun 2007

I just spent a bit of time searching the forums for how to override a style on a custom page and I didn't find anything, so I thought I'd post this in case someone else searches for this in the future.

I spent some time reading through the vBulletin code and realized that regardless of which style variables you modify in your custom php page, they are redefined in init.php and global.php when you include global.php in your script. You can't add anything after global.php because the style has already been processed.

The only way it can be done without editing vBulleting files is through a hook.

Simply go to your AdminCP and click the "Add New Plugin" under the Plugins and Products manager. Since your custom page is a product (you should already have defined this), make sure to change the Product Name dropdown to whatever you've named it.

Select 'style_fetch' from the Hook Location dropdown, describe the plugin, and modify this based on your own code settings:

PHP Code:
if ($youroptions['forcestyle'] == true) {
    
$styleid = ($youroptions['forcedstyleid']);


This will work for simple scripts, but you will run into problems if you are using the vBulletin database class or input cleaner to help determine whether the style should be overwritten.

In this case, you could code your logic into an include script which is only called if this is a custom page.

In your custom pages, you should have

PHP Code:
define('THIS_SCRIPT''yourcustomscriptname'); 
And your hook code should read:

PHP Code:
if (THIS_SCRIPT == 'yourcustomscriptname') {
    require  (
'./yourinclude.php');
    if (
$youroptions['forcestyle'] == true) {
        
$styleid = ($youroptions['forcedstyleid']);    
    }


vblts.ru supports vBulletin®, 2022-2024