Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-23-2011, 07:37 PM
Xerosis Xerosis is offline
 
Join Date: Feb 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 10-23-2011, 07:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 10-23-2011, 08:02 PM
Xerosis Xerosis is offline
 
Join Date: Feb 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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(); ?>
Reply With Quote
  #4  
Old 10-23-2011, 09:52 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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}
Reply With Quote
  #5  
Old 10-23-2011, 10:13 PM
Xerosis Xerosis is offline
 
Join Date: Feb 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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(); ?>
Reply With Quote
  #6  
Old 10-23-2011, 10:17 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #7  
Old 10-23-2011, 10:34 PM
Xerosis Xerosis is offline
 
Join Date: Feb 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I see nothing, I'm testing on localhost first!
Reply With Quote
  #8  
Old 10-23-2011, 10:40 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Xerosis View Post
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.
Reply With Quote
  #9  
Old 10-23-2011, 10:45 PM
Xerosis Xerosis is offline
 
Join Date: Feb 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you forgot to include this line of code

PHP Code:
<?php define('WP_USE_THEMES'false); get_header(); ?>
Reply With Quote
  #10  
Old 10-23-2011, 10:47 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Xerosis View Post
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).
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:20 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.05635 seconds
  • Memory Usage 2,265KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (6)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete