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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-26-2008, 12:19 PM
FatalBreeze FatalBreeze is offline
 
Join Date: Apr 2004
Location: Haifa - Israel
Posts: 163
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with some hooks

Hello!
I've built this recursive function and put it in the hook showthread_start:
PHP Code:
function is_parent_forum_is_341_categoty($forum
{  
    
//Returns True if parentid is a 341 category, false otherwise
    
global $vbulletin;  
    if (
$forum['forumid'] == 341)
        return 
true;
    if (
$forum['parentid'] == -1)
        return 
false;
    
$parent $vbulletin->forumcache[$forum[parentid]];
    return 
is_parent_forum_is_341_categoty($parent);
}
$show_ads_in_this_forum = !is_parent_forum_is_341_categoty($foruminfo); 
Now i also want to use in the hook postbit_display_start, but it seems that this hook, doesn't acknlowledge the function i built above, or the variable $show_ads_in_this_forum, what strange is, that when i tried to implment this function is postbit_display_start, i had ad error which said that is function is already implemented somewhere else in the code, and even if i change its name, something that's really weird.

Can you please help? Thanks.
Reply With Quote
  #2  
Old 01-26-2008, 02:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you put a function in postbit_display_start, it gets called everytime the postbit is called on the showthread page - so 15, 20 times (whatever your default is) - which is why you get told the function already exists.
Reply With Quote
  #3  
Old 01-26-2008, 03:48 PM
FatalBreeze FatalBreeze is offline
 
Join Date: Apr 2004
Location: Haifa - Israel
Posts: 163
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're right! Thanks!
So can you please tell me in which hook i should implement this function, in order to be able to use the variable "$show_ads_in_this_forum" in both SHOWTHREAD and in POSTBIT_LEGACY templates?
Reply With Quote
  #4  
Old 01-26-2008, 04:20 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

postbit_legacy (or postbit) is called in the showthread template. So, I would think you would be fine just calling this in the showthread hook. Is it not working in there? You may need to change it from $forum[forumid] and $forum[parentid] to $foruminfo[whatever]. Or, you may need to use $thread instead of $forum. Play around with it a bit. (Sorry, that's the way I code, I just play around with it until it works.)
Reply With Quote
  #5  
Old 01-26-2008, 04:47 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could make use of vB's functions, let it do the hard work for you

PHP Code:
// If $thread doesn't work, try $post or try $foruminfo
$parents fetch_forum_parent_list($thread['forumid']); 

// You may need to use array_map('trim', explode(',', $parents)); if that works though
$parents explode(','$parents); 

if(
in_array('341'$parents))
{
    
// $show_ads_in_this_forum = true; ?

Reply With Quote
  #6  
Old 01-26-2008, 06:29 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why so complicated?

PHP Code:
$show['ads'] = (strpos(",$foruminfo[parentlist],"',341,') !== false) ? true false
on showthread_start and use $show['ads'] in your templates.
Reply With Quote
  #7  
Old 01-27-2008, 07:23 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Andreas, wouldn't that fail if 341 was on the top or bottom of the list?

(ie. only a comma in the end or beginning)

Never mind, i should learn to read things good.
Reply With Quote
  #8  
Old 01-27-2008, 07:47 AM
FatalBreeze FatalBreeze is offline
 
Join Date: Apr 2004
Location: Haifa - Israel
Posts: 163
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Andreas!
You helped me a lot
Reply With Quote
  #9  
Old 01-27-2008, 11:05 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Marco van Herwaarden View Post
Andreas, wouldn't that fail if 341 was on the top or bottom of the list?

(ie. only a comma in the end or beginning)
That's why I added commas on both start and end for needle and haystack
Reply With Quote
  #10  
Old 01-27-2008, 11:58 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes saw that after i posted, hence my last line (which you did not quote )
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 01:24 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.04457 seconds
  • Memory Usage 2,254KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete