vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Where this hook edit should go... (https://vborg.vbsupport.ru/showthread.php?t=106326)

Logikos 01-25-2006 09:52 PM

Where this hook edit should go...
 
Hey guys, Maybe you can help me out. I'm creating a new condition to be able to use in the postbit template. The condition will be something like this:

HTML Code:


<if condition="$check">
        <!-- $check holds information -->
<else />
        <!-- $check doesn't hold information -->
</if>

The '$check' variable will be determined like this:

PHP Code:

        $checkdata $db->query_read("
                SELECT dateline
                FROM " 
TABLE_PREFIX "custom
                WHERE userid = " 
$vbulletin->userinfo['userid'] . "
                        AND threadid = " 
intval($threadid)
        );

        if (
$db->num_rows($checkdata))
        {
                
$check true;
        }
        else
        {
                
$check false;
        } 

Now I want to beable to use that in my postbit_legacy template. Any ideas where in showthread.php to add the PHP code? I've tried ALL avalible hooks and none worked. Thanks

Xenon 01-25-2006 09:59 PM

place it in postbit_display_start and make sure via a static variable, that the query just runs once!

Logikos 01-25-2006 10:36 PM

Thanks Xenon, though that doesn't seem to work as expected. It seemed to add one addional query for each post per page. The condition didn't seem to work also.

Basicly I need a query to check that database to see if the user who is viewing the threadid is in the database table. If he is show X if he isn't show Y. Normaly I would just add this to the showthread.php and it works fine. Though I have to add this to the postbit template. So theres no reason to run 10 extra queries when they will always equal the same thing.

The problem is getting the condition to work in the postbit template. :)

Xenon 01-26-2006 10:56 AM

that's why i said you need a static variable to run it just once ;)

PHP Code:

static $alreadychecked$check;

if (!
$alreadychecked)
{
$checkdata $db->query_read("
                SELECT dateline
                FROM " 
TABLE_PREFIX "custom
                WHERE userid = " 
$vbulletin->userinfo['userid'] . "
                        AND threadid = " 
intval($threadid)
        );

        if (
$db->num_rows($checkdata))
        {
                
$check true;
        }
        else
        {
                
$check false;
        }
$alreadychecked true;



Logikos 01-26-2006 01:52 PM

Quote:

Originally Posted by Xenon
that's why i said you need a static variable to run it just once ;)

Yea I know and I tried using a static variable. Heres the code I used in ": postbit_display_start".

PHP Code:

global $db$vbulletin;
static 
$alreadychecked$check;

if (!
$alreadychecked)
{
        
$checkdata $db->query_read("
                SELECT dateline
                FROM " 
TABLE_PREFIX "custom
                WHERE userid = " 
$vbulletin->userinfo['userid'] . "
                        AND threadid = " 
intval($thread['threadid']) . "
        "
);

        if (
$db->num_rows($checkdata))
        {
                
$check true;
        }
        else
        {
                
$check false;
        }

        
$alreadychecked true;



The conditions worked for each postbit, but its still running the query for each postbit. =\ I had to add:

PHP Code:

global $db$vbulletin

Or it would give me a "Fatal error: Call to a member function on a non-object in /home/vbhacker/public_html/jelsoft/includes/class_postbit.php(251) : eval()'d code on line 6"

amykhar 01-26-2006 02:00 PM

Would it work to put the query in showthread and assign the results to a variable? Then in postbit, you could declare the variable global and check the value. Might be worth a shot.

Xenon 01-26-2006 02:43 PM

hmm, that should be possible as well amy.

as for the other thing, that seems to be a glitch in the plugin system, or better said in the eval() function of php... not the first one i noticed... ^^

Logikos 01-26-2006 02:52 PM

Should I ask vBulletin about this and see if its a glitch in the plugin system?

Also Amy: Are you saying add the query to showthread_start and use $GLOBALS[]?

Xenon 01-26-2006 02:58 PM

nope, its a provlem in the eval function, which is used by vbulletin.

and to answer question two.
that would be possible, but it should be enough to use global variablename in the postbit plugin ;)

amykhar 01-26-2006 03:04 PM

What stefan said.


All times are GMT. The time now is 03:06 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.02671 seconds
  • Memory Usage 1,754KB
  • 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_html_printable
  • (4)bbcode_php_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