vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Requires with plugin (https://vborg.vbsupport.ru/showthread.php?t=168991)

RobDog888 01-28-2008 06:34 PM

Requires with plugin
 
<font color="darkgreen">I am trying to add additional content to the postbit template conditionally and pulling in a template bit with the php code in a requires statement in the plugin.

Usually not a problem but Im getting errors when I try to call a "$db->query_read( blah, blah " statement. Says object null or required.

Even with a single line of code in my requires php page I get the $db is null. What could be the issue?

Im using showthread_postbit_create or postbit_start hook location(s) as either will generate the same error.

Thanks</font>

Andrew Green 01-28-2008 06:37 PM

try "$vbulletin->db->query_read"

RobDog888 01-28-2008 06:56 PM

Thanks for the quick reply.

I still get a ...
Code:

Fatal error: Call to a member function on a non-object in .... forums/includes/class_postbit.php(268) : eval()'d code on line 9
Line 9 in the plugin is "$vbulletin->db->query_read("" as I commented out the requires to simplify things and moving it all into the plugin for testing only.

Opserty 01-28-2008 07:14 PM

$this->registry->db->query_read()

or

$this->dbobject->query_read()

RobDog888 01-28-2008 07:28 PM

I get these errors for each suggestion respectivly.

Quote:

Fatal error: Call to undefined method: vb_registry->query_read()

Fatal error: Call to a member function on a non-object
--------------- Added [DATE]1201556097[/DATE] at [TIME]1201556097[/TIME] ---------------

postbit_display_start is in the class_postbit.php which is not really where I think I should be using for the location hook but it works when I dont execute a query.

The construct_postbit is the function where that hook is located. Couldit be possible that the location of the hook is the issue?

Opserty 01-28-2008 07:42 PM

I'll take a look at the file in a sec. but just to check did you use:

$this->registry->db->query_read()

Because according to your error I'm guessing you did $this->registry->query_read() which isn't correct.

RobDog888 01-28-2008 07:47 PM

I changed it and retested it and same error.

$myvar = $this->registry->db->query_read("SELECT * FROM Table1");



Thanks I appreciate all the help guys :)

Ps, I changed the hook location to "showthread_post_start" but still errors but I think thats the best hook

Opserty 01-28-2008 07:54 PM

In showthread_... you should be able to use $vbulletin->db->query_read() or $db->query_read().

As a last resort you can try $GLOBALS['vbulletin']->db->query_read()

RobDog888 01-28-2008 08:08 PM

For some weird reason the plugin wont display static text with showthread_post_start but it does with postbit_display_start.

I tried your latest suggestion $GLOBALS['vbulletin'] and it worked! I got a simple query to run and display the number of records returned in the postbit template with postbit_display_start. Thanks a million :D

I dont know why I have to use the hook in the class_postbit.php file but maybe it has to do with order of execution or something?

sinisterpain 01-28-2008 08:22 PM

Would be more helpful to post what you have


All times are GMT. The time now is 11:47 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.01118 seconds
  • Memory Usage 1,730KB
  • 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)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