vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Template Variable Issue (https://vborg.vbsupport.ru/showthread.php?t=315830)

KGodel 12-05-2014 08:37 PM

I think we're good for now. If I run my select at showthread_start and simply save everything to $countries, will that be accessible by my plugin in the postbit?

After testing, it seems no matter where I put the $countries selection it does not execute. Do sql executions not work in plugins?

nerbert 12-05-2014 09:36 PM

I do queries all the time with them. As long as your query comes after the file has required global.php you'll have a database connection. Do you have a function that needs $countries? Use "global $countries;" in it.

If your plugin is inside an existing vbulletin function (and I suspect it is) you have to get $countries inside the function. You could use the line

$vbulletin->countries = $countries;

after your query and then refer to it that way in your plugin, or if that doesn't work refer to it as

$this->registry->countries

in your plugin.

KGodel 12-05-2014 10:05 PM

Okay, here are my plugins, which are not working (or at least no flags are showing up):
showthread_start
PHP Code:

$sql "SELECT * FROM " TABLE_PREFIX "countrycodes";
        
$result $db->query_read_slave($sql);
        
        while (
$c mysql_fetch_array($result) {
            
$countries[$c[0]] = $c[1];
        }

$vbulletin->countries $countries

postbit_display_complete
PHP Code:

$ccode array_search($post['field58'], $vbulletin->countries);

    if (
$ccode != null) {
        
$imgoutput "<img src='images/flags/$ccode.png' class='inlineimg' alt='$country' />&nbsp;&nbsp;";
    }

$templatevalues['ccimg'] = "$imgoutput";
vB_Template::preRegister('postbit_legacy'$templatevalues); 

Note: When I attempt to var_dump the $countries array after it's created, I get null, so the query itself is not being executed, even though you'd think that this was LONG after the global.php had been included...

nerbert 12-06-2014 12:34 AM

I'm not very good with sql. What are your actual field names? I would try using those instead of 0 and 1.

And try

$result = $vbulletin->db->query_read_slave($sql);

$db doesn't always work but $vbulletin->db should

KGodel 12-06-2014 12:35 AM

Update: When I switched from using the $vbulletin->db commands to just using mysql_ commands everything worked. ^^

nerbert 12-06-2014 03:00 AM

That's strange. When you require global.php it requires various other files such as includes/core.php which has all the database stuff.

Glad you got it working.


All times are GMT. The time now is 03:31 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.01053 seconds
  • Memory Usage 1,734KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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