vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How include two php file using hook location global_start (https://vborg.vbsupport.ru/showthread.php?t=317761)

mondingnibai 03-13-2015 12:54 AM

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

kh99 03-13-2015 10:44 AM

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::preRegister 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.

mondingnibai 03-14-2015 12:10 AM

@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.

kh99 03-14-2015 12:26 AM

Oh, I see now. Sorry, I didn't read your post carefully. Anyway, maybe try using ob_end_clean() in place of ob_clean().

mondingnibai 03-14-2015 12:55 AM

@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.

kh99 03-14-2015 02:42 AM

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.

mondingnibai 03-26-2015 12:59 AM

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.


All times are GMT. The time now is 02:30 PM.

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.01224 seconds
  • Memory Usage 1,723KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete