Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2006, 09:52 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 01-25-2006, 09:59 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

place it in postbit_display_start and make sure via a static variable, that the query just runs once!
Reply With Quote
  #3  
Old 01-25-2006, 10:36 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 01-26-2006, 10:56 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;

Reply With Quote
  #5  
Old 01-26-2006, 01:52 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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"
Reply With Quote
  #6  
Old 01-26-2006, 02:00 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 01-26-2006, 02:43 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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... ^^
Reply With Quote
  #8  
Old 01-26-2006, 02:52 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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[]?
Reply With Quote
  #9  
Old 01-26-2006, 02:58 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #10  
Old 01-26-2006, 03:04 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What stefan said.
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 12:10 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.07891 seconds
  • Memory Usage 2,277KB
  • Queries Executed 11 (?)
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_html
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete