vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   header (https://vborg.vbsupport.ru/showthread.php?t=272602)

Xerosis 10-23-2011 07:37 PM

header
 
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?

kh99 10-23-2011 07:48 PM

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 Code:

<?php
require('C://wamp\www\wp-blog-header.php');
?>
<?php define
('WP_USE_THEMES'false); get_header(); ?>


kh99 10-23-2011 09:52 PM

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/..._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):
PHP Code:

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:
Code:

{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 Code:

<?php
require('C://wamp\www\wp-blog-header.php');
?>
<?php define
('WP_USE_THEMES'false); get_header(); ?>


kh99 10-23-2011 10:17 PM

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!

kh99 10-23-2011 10:40 PM

Quote:

Originally Posted by Xerosis (Post 2260692)
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:

PHP Code:

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 Code:

<?php define('WP_USE_THEMES'false); get_header(); ?>


kh99 10-23-2011 10:47 PM

Quote:

Originally Posted by Xerosis (Post 2260698)
I think you forgot to include this line of code

PHP 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).


All times are GMT. The time now is 03:08 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01106 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete