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 03-13-2015, 12:54 AM
mondingnibai mondingnibai is offline
 
Join Date: Mar 2015
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How include two php file using hook location global_start

I want to ask how to include two php files separately?using the hook location global start?
Right now, I have two plug-in code namely firstplugin and secondplugin with same code. See below:

firstplugin code:

ob_start();
include('firstplugin.php');
$first= ob_get_contents();
ob_clean();

secondplugin code:

ob_start();
include('secondplugin.php');
$second= ob_get_contents();
ob_clean()

Now, when I activate this two plug-in nothing shows up except for a white backgroud in the browser. Now, when I deactivate either one of the two it works. I run this two plug-ins in one page. I want them to show up. How can I achieve this?How can I include two php files with same code and the same hook location?Need Help ASAP...
Reply With Quote
  #2  
Old 03-13-2015, 10:44 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The second plugin you posted is missing a ';' at the end. Maybe that was just an error copying it here, but if not that may be what's causing the white page. Otherwise, it's probably that it can't find the file you're telling it to include.

To get the output to display, you need to include it in a template in some way. One way is to pre-register it to a template, then edit the template and insert it where you want it to appear. So for example, if you wanted your file to appear in the header of every page, your first plugin might look like this:
ob_start();
Code:
include('firstplugin.php');
$first= ob_get_contents();
ob_clean();
vB_Template::preRegister('header', array('first' => $first));

Then you'd have to edit the header template and insert {vb:raw first} where you want it to appear.

Note that if you use vB_Template:reRegister to insert something in the navbar, headinclude, header, or one of the ad templates, then you need to use hook parse_templates for your plugin.

If you want to know what template to edit, one way to figure that out is to turn on "Add Template Name in HTML Comments" by going to Settings > Options > General Settings in the admincp. Then if you view the html source of a vbulletin page in your browser, you should see comments telling you when specific templates begin/end.
Reply With Quote
  #3  
Old 03-14-2015, 12:10 AM
mondingnibai mondingnibai is offline
 
Join Date: Mar 2015
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@kh99 when I add the semicolon at the end its still the same happend nothings appears. I already preRegister the template already.

But when I activate one by one it works but when I activate the two nothing appears and it shows me white background.
Reply With Quote
  #4  
Old 03-14-2015, 12:26 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, I see now. Sorry, I didn't read your post carefully. Anyway, maybe try using ob_end_clean() in place of ob_clean().
Reply With Quote
  #5  
Old 03-14-2015, 12:55 AM
mondingnibai mondingnibai is offline
 
Join Date: Mar 2015
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@kh99 I already use that also but nothing happens. I really dont know what's the reason.

--------------- Added [DATE]1426298238[/DATE] at [TIME]1426298238[/TIME] ---------------

Is it possible to create plug-in with the same hook location?and execution order?with the same products?
I am using the hook location global_start.
Reply With Quote
  #6  
Old 03-14-2015, 02:42 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, it's ok to do that. If the execution order is the same, I don't think you'll know for sure which one will run first, but it doesn't look like that should matter.

The problem could be in the other code in the plugin, or in the include files. Maybe they conflict somehow, like if they define the same function. If that's the problem, then you might have to make changes to the included files.
Reply With Quote
  #7  
Old 03-26-2015, 12:59 AM
mondingnibai mondingnibai is offline
 
Join Date: Mar 2015
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got it working @kh99, thanks for your time and giving me some tips on how to check it. Yup, there is a conflict in function and I change it and right now its working perfect. Thanks dude.
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 05:06 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03886 seconds
  • Memory Usage 2,217KB
  • 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
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete