vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help with some hooks (https://vborg.vbsupport.ru/showthread.php?t=168762)

FatalBreeze 01-26-2008 12:19 PM

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.

Lynne 01-26-2008 02:14 PM

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.

FatalBreeze 01-26-2008 03:48 PM

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?

Lynne 01-26-2008 04:20 PM

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.)

Opserty 01-26-2008 04:47 PM

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

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; ?



Andreas 01-26-2008 06:29 PM

Why so complicated?

PHP Code:

$show['ads'] = (strpos(",$foruminfo[parentlist],"',341,') !== false) ? true false

on showthread_start and use $show['ads'] in your templates.

Marco van Herwaarden 01-27-2008 07:23 AM

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. ;)

FatalBreeze 01-27-2008 07:47 AM

Thanks Andreas!
You helped me a lot :)

Andreas 01-27-2008 11:05 AM

Quote:

Originally Posted by Marco van Herwaarden (Post 1429888)
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 ;)

Marco van Herwaarden 01-27-2008 11:58 AM

Yes saw that after i posted, hence my last line (which you did not quote;) )


All times are GMT. The time now is 09:14 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.01259 seconds
  • Memory Usage 1,740KB
  • 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
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete