PDA

View Full Version : Plugin using global_complete hook, cant exclude from a forum using if conditional


basketmen
07-28-2015, 12:33 AM
This is replacement code from kh99 (https://vborg.vbsupport.ru/showpost.php?p=2402308&postcount=4), using global_complete hook, its works good

$find = 'Post New Thread';
$replace = 'Create a Listing';

$output = str_replace($find, $replace, $output);





but now i want to exclude a forum
already tried wrap it using below if conditional, but its not works
if ($foruminfo['forumid'] != 123)
{
}

if ($thread['forumid'] != 123)
{
}

if ($post['forumid'] != 123)
{
}

what is the right if conditional? or this cant be done because its using global_complete hook? :confused:
please help guys

MarkFL
07-28-2015, 01:12 AM
Try the hook location "forum_display_start" and the plugin PHP code:

if ($foruminfo['forumid'] != 123)
{
$vbphrase['post_new_thread'] = 'Create a Listing';
}

basketmen
07-28-2015, 03:49 AM
its not only for forumdisplay, but for showthread too

it is better using forum_display_start hook or global_complete?

MarkFL
07-28-2015, 04:23 AM
You have a "Post New Thread" button on your "showthread" pages?

basketmen
07-28-2015, 04:32 AM
You have a "Post New Thread" button on your "showthread" pages?
its just example text, i use for some text

MarkFL
07-28-2015, 05:52 AM
Ah okay, your initial post led me to believe you were trying to change the text that displays in the "Post New Thread" button. :)

basketmen
07-28-2015, 06:36 AM
Ah okay, your initial post led me to believe you were trying to change the text that displays in the "Post New Thread" button. :)
thank you for the alternative way using forum_display_start hook


so what is the right if conditional to exclude a forum with global_complete hook?

MarkFL
07-28-2015, 07:08 AM
The forumid data does not appear to be available at that hook.

Easy5s.net
07-28-2015, 10:03 AM
try $GLOBAL['forumid']

basketmen
07-28-2015, 01:17 PM
try $GLOBAL['forumid']
thank you for reply, tried this

if ($GLOBAL['forumid'] != 123)
{
}

but looks like not working, still same like not using it
any other code?



The forumid data does not appear to be available at that hook.
hmm if its true, the only way is using forum_display_start hook and one more plugin for shothread_start

kh99
07-28-2015, 03:56 PM
global_complete is one of the last things called. I think what you want is something like global_setup_complete.

I was looking at code a little, and while I'm sure in th past I've suggested that people use $forumid or $GLOBALS['forumid'] (it has an 'S' at the end), it looks like that's a bad one to use unless you're using a hook that's only called on forum.php. It looks like most of the time, $foruminfo['forumid'] is what you'd want (unless you know you're interested in $threadinfo or $post).

basketmen
07-28-2015, 11:51 PM
global_complete is one of the last things called. I think what you want is something like global_setup_complete.

I was looking at code a little, and while I'm sure in th past I've suggested that people use $forumid or $GLOBALS['forumid'] (it has an 'S' at the end), it looks like that's a bad one to use unless you're using a hook that's only called on forum.php. It looks like most of the time, $foruminfo['forumid'] is what you'd want (unless you know you're interested in $threadinfo or $post).
$GLOBALS['forumid'] with global_complete hook is works

global_setup_complete hook not works


thank you kh99, MarkFL & Easy5s.net

kh99
07-29-2015, 08:06 AM
$GLOBALS['forumid'] with global_complete hook is works

global_setup_complete hook not works


thank you kh99, MarkFL & Easy5s.net

Oh, right, I see now that you're doing str_replace() on $output. That would have to be done at the end using global_complete. I'm still kind of surprised that $GLOBALS['forumid'] works, but I can't argue with success.