View Full Version : header
Xerosis
10-23-2011, 07:37 PM
Hi, I want to add a code in the header of my forum and I would like to know in which file I can put it, I would like for it to appear in every page like if it was part of the forum, in this moment I'm using global.php, what do you say?
When you say you want it in the header, do you mean between the html header tags, or part of the forum header? If you mean the tags, then put it in the headinclude template, otherwise put it in the header template.
That assumes you mean html code or javascript. If you mean php code then you need to create a plugin.
Xerosis
10-23-2011, 08:02 PM
yes the code is in php...
i want to put the wordpress header in vbulletin
<?php
require('C://wamp\www\wp-blog-header.php');
?>
<?php define('WP_USE_THEMES', false); get_header(); ?>
Fortunately someone just asked a similar question so I've got it all written up: You need to put your code in a plugin. Here's the manual page for creating a plugin: https://www.vbulletin.com/docs/html/main/add_plugin
You will need to buffer the output and capture it in a string variable, then register that variable to a template, then add a tag to the template. Here's the manual page that describes including an external file that produces output: https://www.vbulletin.com/docs/html/main/templates_externalfiles . The code to regiater a variable to a template is below that. Then you need to add your variable in the header template. So the whole thing together might look like this:
Plugin code (hook location global_start):
ob_start();
require('C://wamp\www\wp-blog-header.php');
$wpheader = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('header', array('wpheader' => $wpheader));
Then in the header template:
{vb:raw wpheader}
Xerosis
10-23-2011, 10:13 PM
The code you posted doesn't work, I am using this code on "global.php" and works but the problem is that changes the font of vbulletin
<?php
require('C://wamp\www\wp-blog-header.php');
?>
<?php define('WP_USE_THEMES', false); get_header(); ?>
What happens, do you see nothing, or you see the forum but without the wp header? I notice that your require'd file starts with C://, are you sure that path is correct?
Xerosis
10-23-2011, 10:34 PM
I see nothing, I'm testing on localhost first!
The code you posted doesn't work, I am using this code on "global.php" and works but the problem is that changes the font of vbulletin
Well, given the code you poster above, I guess the plugin code would have to be:
ob_start();
require('C://wamp\www\wp-blog-header.php');
define('WP_USE_THEMES', false);
get_header();
$wpheader = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('header', array('wpheader' => $wpheader));
But I don't know, I'm not familiar with wp. I guess there could be some conflict between vb and the wp code that's messing up the font. Maybe someone else can help.
Xerosis
10-23-2011, 10:45 PM
I think you forgot to include this line of code
<?php define('WP_USE_THEMES', false); get_header(); ?>
I think you forgot to include this line of code
<?php define('WP_USE_THEMES', false); get_header(); ?>
Oh, yeah - I did forget it in the original plugin code I posted above - sorry about that (or did you just edit post #3 and insert it?). I included it in the updated version above. (You don't need the <?php and ?> tags in a plugin).
Xerosis
10-23-2011, 10:52 PM
I think the code has some error because I created a test.php and it won't get the head from wordpress anyway with that code :c
I know if you were trying to do the opposite (include vb code in wordpress or some other program), it has a problem because global.php can only be included from the current directory. So to include vb code you have to do something like:
$savedir = getcwd();
chdir("path_to_vb_forum_dir");
require_once("./global.php");
chdir($savedir);
So maybe you could try something like that.
Xerosis
10-23-2011, 11:04 PM
I think the problem wa this:
ob_end_clean();
it is possible import the vbulletin header ?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.